Question: Step 2 : In this part, we add implementation to existing design 1 . Add a boolean instance variable to GreenhouseControls called fans . Create

Step 2: In this part, we add implementation to existing design
1. Add a boolean instance variable to GreenhouseControls called fans. Create two Event classes called FansOn and FansOff. The action() of these two classes should modify fan to true or false respectively.
2. Modify Bell Event so that it will be able to run an arbitrary number of times separated by 2000 msec each. To facilitate this requirement, you should generate the number of Bell Events specified in the rings parameter in the examples file. Please pay special attention to the possibility that other events might be run in between the various Bell events.
3. Modify Restart.action() to start the the system by reading events from a text file. Use Scanner and an appropriate regular expression.
4. Try running GreenhouseControls by:
java GreenhouseControls -f examples1.txtu
and
java GreenhouseControls -f examples2.txt
5. The -f argument must be present. It must be either -f or -d. Please see Part 4. The event information must be in the format specified in examples1.txt and examples2.txt.
Step 3: Add functionality to simulate problems
1. Create a WindowMalfunction and PowerOut Events to simulate problems that may occur in a GreenhouseControls. The event should set the following boolean variables as appropriate in GreenhouseControls:
windowok = false;
poweron = false;
After setting the variables, WindowMalfunction or PowerOut should throw an exception specifying the faulty condition. Create a ControllerException class that extends Exception for this purpose.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!