1 Make Event implements Runnable so that each type of event

1. Make Event implements Runnable so that each type of event provides its own timing. Each event file should be a class of its own. Change the rest of the design to simplify this model.

2. Provide the means to create the event classes from their names (see the Constructor class in java.lang.reflect and getConstructor() in the Class Class). Use the same capability to be able to add new Event classes and modify Event classes without recompiling GreenhouseControls.java (remove all the classes as inner classes and make them public classes in their own file). Start the Event thread right after you have successfully created the Event object. Make whatever changes are required to the overall design.

3. Events should be started once they are created. Devise a mechanism for GreenhouseControls to suspend and resume the Event threads. To do this GreenhouseControls needs to keep a collection of threads of all events.

4. Remove all existing states variables in GreenhouseControls and replace them by using a collection of TwoTuple (See examples in TIJ pages 621 to 624). Each time an event runs it should add an entry that identifies the variable the event is modifying as key, and another object to this structure as the value the event is setting. Create a method in GreenhouseControls called setVariable to handle updating to this collection. Use the synchronization feature in java to ensure that two Event classes are not trying to add to the structure at the same time. Again make whatever changes are required to the overall design. Provide adequate methods to access the state variables.

5. Design and implement a mechanism for each event to output the description to a GUI interface

Part2:

This part aims to develop a Graphical User Interface used to control a GreenhouseControls object. You are free to design the layout of the interface. In case you are not sure you may develop the interface that looks like this, this or this. The minimum number of components and their functionalities of the GUI are:

1. Each window of the GUI must have a scrollable text area, a set of 5 buttons, a pulldown menu and a popup menu.

2. The pulldown menu consists of the following sub menus:

New window - creates a new GUI window. The new GUI window should associate with another GreenhouseControls object.

Close window - closes the current window. If the GreenhouseControls object is running, a warning message should be displayed to ask the user to confirm closing of the window. If the current window is the only window opened, exit the application.

Open Events - opens an events file. It should bring up a file dialog and let the user chooses an event file. If the chosen file is not a valid event file, display an appropriate error message.

Restore - opens a dump.out file and restore the GreenhouseControls object. It should bring up a file dialog and let the user choose a dump.out file. If the chosen file is not a valid dump.out file, display an appropriate error message. This option should be disabled if the GreenhouseControls is running.

Exit - exit the application. If any of the opened GUIs is running a GreenhouseControls object, display a warning message to ask the user to confirm the exit.

Associate a keyboard shortcut with each of the above menu items.

3. The buttons:

Start - start to run a GreenhouseControls object. This button should be disabled if the GreenhouseControls object is running.

Restart - add a Restart object to rerun the current event file. This button should be disabled if no events file is read, or if the GreenhouseControls object is running.

Terminate - add a Terminate event to the running GreenhouseControls object. It should bring up a dialog to prompt for the delay time in milliseconds. This button should be disabled if the GreenhouseControls object is not running.

Suspend - suspends all running event threads. This button should be disabled if the GreenhouseControls object is not running.

Resume - resume all suspended event threads. This button should be disabled if the GreenhouseControls object is running.

4. The popup menu should contain the following 5 submenus: Start, Restart, Terminate, Suspend, and Resume, with the same functionalities as the buttons.

5. In addition to the above components, you are free to add as many components as necessary to make the GUI look nice.

The program should look likeany of the three images for second part:

Solution

Event.java

1. Make Event implements Runnable so that each type of event provides its own timing. Each event file should be a class of its own. Change the rest of the desig
1. Make Event implements Runnable so that each type of event provides its own timing. Each event file should be a class of its own. Change the rest of the desig

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site