Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need to make a microwave oven program using CRC classes like beeper button cancelbutton cookbutton door light microwave mytimer(code included below) oven powertube The question

Need to make a microwave oven program using CRC classes like beeper

button

cancelbutton

cookbutton

door

light

microwave

mytimer(code included below)

oven

powertube

image text in transcribed

The question is stated in the picture above.

Here is the mytimer code:

package microwave;

import java.util.Timer;

import java.util.TimerTask;

public class MyTimer {

private int time; //as seconds

private boolean isrunning;

Timer t;

Oven oven;

public MyTimer(Oven oven){

isrunning = false;

time = 0;

this.oven = oven;

}

public void Add1Minute(){

if(isrunning) return;

t= new Timer();

time = 60;

isrunning = true;

System.out.println("Added 1 minute of cook time");

StartTimer();

public void AddExtraMinute(){

time = time + 60;

System.out.println("Added 1 minute of cook time");

}

private void StartTimer(){

t.scheduleAtFixedRate(new TimerTask(){

public void run(){

System.out.println(time);

time--;

if(time == 0){

Alert();

t.cancel();

}

}

}, 0, 1000); //TimerTask, startAtOnce, Milliseconds

}

private void Alert(){

oven.TimerExpired();

isrunning = false;

}

boolean isRunning(){

return isrunning;

}

public void Cancel(){

t.cancel();

time=0;

isrunning = false;

}

}

Task: Implement your CRC classes in Java. Of course this program is just a simulator - it doesn't actually cook. But do the following: 1 As text output when the door is opened display a message "Door is open" 2. When the door is closed display a message "Door is closed" 3. When the cook button is pressed display a. Light is on b. Added 1 minute of cook time C. Power tube is on... d. Beep! 4. Start a countdown from 60 seconds and display the time 5. If the door is open and the cook button pressed just beep and do nothing else 6. Use d' to toggle the door open and closed 7. Use p'to press the cook button 8. When cooking is done (timer reached zero) display a. Light is off b. Beep c. Beep! d. Beep! 9. If p'is pressed while the oven is running, add 60 seconds to cook time. The number of seconds remaining should be equal to 60 plus whatever amount of time was at the point of pressing 'p 10. If 'c' is pressed while the oven is running, turn off the light, the power tube, zero the timer and beep. If not running just beep. Display a. Light is off b. Beep c. Cooking cancelled by pressing Cancel 11. If 'd' is pressed while oven is running, turn off the light, the power tube, zero the timer and beep. If not running justb eep. Display oor a. Cooking cancelled by opening d b. Light is on Since the oven has no display the messages printed in the simulator are for our reference only. The oven would not actually display anything but we could certainly see the light and hear the beeper the power tube You might want to use my myTimer class. myTimer has a separate thread of execution so the timer can run and return to the oven so the oven can continue to accept and process input. Task: Implement your CRC classes in Java. Of course this program is just a simulator - it doesn't actually cook. But do the following: 1 As text output when the door is opened display a message "Door is open" 2. When the door is closed display a message "Door is closed" 3. When the cook button is pressed display a. Light is on b. Added 1 minute of cook time C. Power tube is on... d. Beep! 4. Start a countdown from 60 seconds and display the time 5. If the door is open and the cook button pressed just beep and do nothing else 6. Use d' to toggle the door open and closed 7. Use p'to press the cook button 8. When cooking is done (timer reached zero) display a. Light is off b. Beep c. Beep! d. Beep! 9. If p'is pressed while the oven is running, add 60 seconds to cook time. The number of seconds remaining should be equal to 60 plus whatever amount of time was at the point of pressing 'p 10. If 'c' is pressed while the oven is running, turn off the light, the power tube, zero the timer and beep. If not running just beep. Display a. Light is off b. Beep c. Cooking cancelled by pressing Cancel 11. If 'd' is pressed while oven is running, turn off the light, the power tube, zero the timer and beep. If not running justb eep. Display oor a. Cooking cancelled by opening d b. Light is on Since the oven has no display the messages printed in the simulator are for our reference only. The oven would not actually display anything but we could certainly see the light and hear the beeper the power tube You might want to use my myTimer class. myTimer has a separate thread of execution so the timer can run and return to the oven so the oven can continue to accept and process input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

2. Prevent fights by avoiding crowded work spaces.

Answered: 1 week ago

Question

LO2 Discuss important legal areas regarding safety and health.

Answered: 1 week ago