CMSC 433 - Project 3: Coffee Shop Simulation

Due by 23:59:59 on Friday, April 12th.

Project Overview

  • You will write the simulation of a coffee shop as with the key difference that you will no longer be allowed to use synchronized or wait or notify or ReentrantLock objects. Instead, you will need to use concurrent collections and blocking data structures.
  • You will implement a Validate method that takes an event list and determines whether it represents a valid simulation run.


    General Requirements

    First, you'll need to check out P3 and then copy the files that are currently in your P2 into the new P3. Do not copy the P2 versions of the files that are provided in the new P3, just the P2 files that are not in the new P3 CVS repository. After you do the copy and paste of a file, you'll also need to update the package name at the top. Then, please move the line in the runSimulation class that is Random rnd = new Random(27); so that it is right before the for loop, not inside it. This was a cut and paste error on my part in P2, but for P3 I'd like it so that different "random" orders are being used for each customer. The seed means that every run gets the same random sequence, but I didn't intend for every customer to also get the same order list.

    Second, you must use concurrent collections this time! You cannot use things like synchronized or ReentrantLock or calls to wait, notify, and notifyAll anymore! You need to implement the safe simulation, but this time using things like concurrent collections and blocking data structures to accomplish your goals. So, modify the files now in the P3 project to match this new goal.

    Third, you must implement a method to validate the output of the simulation. In the example main program this is written to be executed immediately after your simulation completes, to validate its output. For testing on the submit server, we use our version. We will test your version by feeding various lists of events to it during the "secret" testing part of the project testing. To make sure that you have written the Validate method in a stand-alone manner, you should run the Junit tests we provide in ExampleValidateTests.java and make sure that they pass (the first checks that a valid events list is marked as valid and the second checks that an invalid events list is marked as invalid). Please note that I might add a few more tests to my grading validation code now that I know you will all be writing validations test as well, and be in a better position to track down flaws.

  • Validate.java - defines method to validate the results of the simulation - you can use this to test your own code but we will manually test this as part of the "secret" testing.

  • Again, you must make sure that the ExampleValidateTests Junit test compile and work with what you submit. If you wrote your code such that this test does not compile you need to change your project so that it will compile with that example set of validate tests. Be very careful with making things static since some of our test classes will have multiple JUnit cases and making something static that should not be can cause those to break.


    Testing Your Code

    Again, we have allowed a fair amount of freedom in the design of your classes for this project. You'll probably use much of your project 2 structure for this project, but you might find you need to change how you approach certain things, so be sure to test things out. Once again, because of this freedom, and the nature of the submit server, constructing generic unit-level tests poses a problem. We've again set up preliminary public tests that will give you a sense of whether you are on the right track, but once the project deadline has passed and we're ready to do full grading, we will test your code with our own validators, and possibly with manual command line testing, to check a variety of simulation characteristics. We'll also test to see if your validator finds problems in flawed versions of the simulation.

    In order to test your code with our own validator, we have asked you to place all simulation code into a method Simulation.runSimulation() which returns a List of SimulationEvent objects which we can then pass directly to things like the Validate.validateSimulation() method.


    What to Turn In

    Every file you submit should have your name and UID. To enforce academic integrity, Code will be checked for similarity to other submissions. Each student should make his or her own individual submission. Use Eclipse to submit your project.

    Due to the non-deterministic nature of multi-threaded code, a portion of your project grade will come from manual inspection of your code, and since there are many approaches, our understanding will be guided by your description. Therefore, it is in your best interest to provide a sufficient amount of detail in your comments order to reduce the chance for misinterpretation.




    Web Accessibility