public class FoodOrder { private int numChBurgers; //number of Cheese Burgers or
ID: 3915430 • Letter: P
Question
public class FoodOrder { private int numChBurgers; //number of Cheese Burgers ordered private int numPepsis; //number of Pepsis ordered private boolean hasNotPaid; // true if the order has not been paid for } 1.Write a constructor for the FoodOrder class that will accept two input arguments as the initial values of the attributes. 2.Write an overloaded constructor for the FoodOrder class that will take a single argument for the number of CheeseBurgers. 3.Write a set method (also known as a mutator method) for the numPepsis attribute. 4.Write a get method (also known as a accessor method) for the hasNotPaid attribute.
Explanation / Answer
1.
public FoodOrder(int numChBurgers, int numPepsis) {
this.numChBurgers = numChBurgers;
this.numPepsis = numPepsis;
this.hasNotPaid = false;
}
2.
public FoodOrder(int numChBurgers) {
this.numChBurgers = numChBurgers;
this.numPepsis = 0;
this.hasNotPaid = false;
}
3.
public void setHasNotPaid(boolean hasNotPaid) {
this.hasNotPaid = hasNotPaid;
}
4.
public void setNumPepsis(int numPepsis) {
this.numPepsis = numPepsis;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.