Write a class Microwave that has the following Instance Variables Type - assumed
ID: 656772 • Letter: W
Question
Write a class Microwave that has the following Instance Variables Type - assumed to be the name brand Minutes - cannot go above 59 and is a whole number Seconds - cannot go above 59 and is a whole number Constructors A default constructor set the Type, minutes and seconds to some default value Another constructor that takes a type, n minutes value, and a seconds value as parameters and sets those values (making sure each value is valid) Accessors and Mutators for each instance variable Make sure to check for valid values! Methods A method setCookTime which takes in minutes and seconds as parameters and sets those values and returns no value. Also make sure to check for valid values. An overloaded method setCookTime which only takes in only a seconds value, converts the value into minutes and seconds, and finally sets the instance variables minutes and seconds to those values. This method returns no value, but it must also check for valid values. Static Methods A method makeMagicChef which returns a new instance of a Magic Chef brand microwave with the minutes and seconds both set to 0.Explanation / Answer
public class Microwave {
private String type ;
private int minutes;
private int seconds;
//default constructor
Microwave type=new Microwave();
Microwave minutes=new Microwave();
Microwave seconds=new Microwave();
//parametrized constructor
Microwave(String i,int m, int s){
type= i;
minutes = m;
seconds = s;
}
public void setCookTime (Time howLongToCook) {...}
public void makeMagicChef (Food coldFood) {...}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.