Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Homework 10: SimLaundry 2010

Due 1 Friday, 9 April 2009 2010 at 11:00 A.M. (Wednesday before class)

Preface

This assignment has a long description but the coding involved is straightforward. Most of the code for the full application has been written as support code by the course staff. In the our solution written by the course staff, the remaining code remaining for that you to must write (excluding test code) consists of approximately 175 250 lines (including some terse comments and whitespace lines).

...

The course staff is providing a framework for writing this program that includes many classes and interfaces. The framework is packaged as a zipped DrJava project laundry.zip. This file will unzip into a self-contained file tree with root directory laundry. This directory contains the source tree for the laundry framework with root directory edu, a DrJava project file laundry.drjava and two text files sampleIn and sampleOut used by the sample laundry test class edu.rice.comp211.laundry.tests.LaundryTest. Given the text input in sampleIn, your program should generate the text in sampleOut. The provided framework compiles but LaundryTest will fail because most of the members in two the key classes class DoCommandVisitor and Student have been stubbed out.

After unzipping the laundry.zip file, you can open the DrJava laundry project by starting DrJava, setting the Language Level to Full Java, pulling down the Project menu and selecting the Open command. In the file chooser that pops up, select the project profile file laundry.drjava embedded in the file in the unzipped file tree for laundry.zip. You can save the project state at any point during a DrJava session using the Save command in the Project menu. You can also save individual files within the project using the Save button on command file or the File menu.

The Test Project Test commands runs all of the JUnit test files in the project.

...

  • the name of the student,
  • the closet shelf with its piles of clean clothes,
  • the dirty laundry pile, and
  • the laundry room with its piles of laundered garmets sitting on tables.
  • and methods to manipulate those data representations to perform the specified simulation

Wiki MarkupWhen the simulation begins, Acker is wearing _white_ pants, _white_ socks, and a _white_ shirt. The closet shelf, dirty laundry pile, and laundry facilities are all initially empty. The program starts execution using the special method {{public static void main(String\[\] args)}} in class {{Main}}. The {{main}} method interface is the only vehicle for executing Java programs directly from the command line. (DrJava has a {{main}} method for this reason.)

Your solution will be graded using the textual interface. Graphical interfaces are notoriously difficult to test and all of the graphical interface code is part of our support code anyway. Your correctness and testing scores (which each count 25% of your grade) will be based on how well your implementation of each command complies with the given specifications and on how well you demonstrate this compliance with test cases. You can test your DoCommandVisitor using the same approach given in our LaundryTest.java class. These tests use the simulate method in Student to drive the execution of DoCommandVisitor. If you write some utility methods fopr BiLists you should separately test these methods. You are NOT responsible for testing any of our support code in laundry.zip including the BiList class.

...

The program includes two class definitions defining unions (composites without recursion): Garment, specifying the representation of garments that appear in the input stream, and Command, specifying the representation of event description commands. Both classes include the hooks required to support the visitor pattern. The data definition for Garment is important because the GUI IOProcess the graphical version of the user interface included in the framework animates the state of your implementation before each command. This IOProcess graphical user interface (GUI) expects the garments that appear as elements in lists (as revealed by the EnumI and ReadIteratorI interfaces) to be instances of the Garment class. Hence, you must use the representation of garments that our class Garment provides.

...

Each call on nextCommand returns the next command in the stream provided by the IOProcess object, until it reaches an end-of-file ({<control>-d} from the keyboard). End-of-file is reported as a null reference of type Command.

...

The program passes a boolean debug flag to (TerminalIO). The value of the flag is true iff the command line argument -d or -debug is passed to main .

The Graphical User Interface (GUI

...

)

The initialization of the GUI creates an Acker Student object and associated DoCommandVisitor. Each GUI event triggers the execution of DoCommandVisitor; in some cases, such as reading input from a file, it triggers the execution of DoCommandVisitor on a stream of Commands. In essence, the event-handling loop built-in to the Java Swing framework is used to drive the computation rather than a separate loop in the main thread such as the one in the simulate method in Student.

The GUI could also have been written as an implementation of the IOProcess interface. This approach, which conforms to the classic "model-view-controller" (MVC) pattern, is more flexible because it decouples the GUI (the view in MVC
terminology) from the model, but it is also more complex because it involves the cooperative execution of
two loops in separate threads--a main program loop in the simulate method of Student and the loop driving the
event-handling thread supporting the processing of GUI inputs. The SimLaundryApplication dispenses with the main program loop by absorbing the application (the model) into the GUI (the view).

...