Question
JAVA public class Pizza { private String Topping; private String Size; private double Price; public Pizza() { setTopping(cheese); setSize(large); setPrice(9.99); } public Pizza(String t, String
JAVA
public class Pizza { private String Topping; private String Size; private double Price;
public Pizza() { setTopping("cheese"); setSize("large"); setPrice(9.99); }
public Pizza(String t, String s, double p) { setTopping(t); setSize(s); setPrice(p); }
public String getTopping() { return Topping; }
public void setTopping(String Topping) { this.Topping = Topping; }
public String getSize() { return Size; }
public void setSize(String Size) { this.Size = Size; }
public double getPrice() { return Price; }
public void setPrice(double Price) { this.Price = Price; }
public void repeatOrder(String Topping, String Size, double Price) { String topping = this.getTopping(); String size = this.getSize(); double price = this.getPrice(); System.out.println("You ordered a" + size + topping + "pizza for $" + price); }
@Override public String toString() { return "Pizza [Topping=" + Topping + ", Size=" + Size + ", Price=" + Price + "]"; }
Create NEW Java class - called PizzaTester
This time, add in a public static void main(String[] args)
We are going to create two pizzas.
The first pizza object uses the constructor that takes no parameters - called this myPizza. (As a reminder - capitalization does matter. Classes are typically uppercase and the objects are camelcase. The word 'Pizza' should match the same as it does in your class definition.)
The second pizza object should use the constructor that passes in the topping, size and price. Pass in the following parameters (in the correct order): It should be an extra large, pepperoni pizza for $13.99. Call this yourPizza.
Change the price of myPizza to be $12.99 and the topping to be mushroom after it's created.
Use the repeatOrder() method from the class to echo the order back each pizza to the user. Remember: the return type is a string so you will need some way to capture that string in the main program - either through a variable or printing the results of repeatOrder() through a print statement.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started