Question: Here is the program: public class PizzaDemo { public static void main(String[] args) { Pizza pizzaStuff = new Pizza (); pizzaStuff.setPizzaSize(5); pizzaStuff.setPizzaCrust(2.0); pizzaStuff.setPizzaSauce(Marinara); pizzaStuff.display(); Pizza

Here is the program:
public class PizzaDemo {
public static void main(String[] args) {
Pizza pizzaStuff = new Pizza ();
pizzaStuff.setPizzaSize(5);
pizzaStuff.setPizzaCrust(2.0);
pizzaStuff.setPizzaSauce("Marinara");
pizzaStuff.display();
Pizza pizzaStuff2 = new Pizza (3, 7.0, "Alfredo");
pizzaStuff2.display();
}
}
THE FOLLOWING IS A DIFFERENT CLASS:
public class Pizza {
private int pizzaSize;
private double pizzaCrust;
private String pizzaSauce;
public Pizza () {
}
public Pizza (int pizzaSize, double pizzaCrust, String pizzaSauce) {
this.pizzaSize = pizzaSize;
this.pizzaCrust = pizzaCrust;
this.pizzaSauce = pizzaSauce;
}
public void display () {
System.out.println("Pizza Size: " + pizzaSize);
System.out.println("Pizza Crust:" + pizzaCrust);
System.out.println("Pizza Sauce:" + pizzaSauce);
}
public void setPizzaSize(int i)
{
pizzaSize = i;
}
public void setPizzaCrust(double c)
{
pizzaCrust = c;
}
public void setPizzaSauce(String s)
{
pizzaSauce = s;
}
public int getPizzaSize() //getter "get"
{
return pizzaSize;
}
public double getPizzaCrust()
{
return pizzaCrust;
}
public String getPizzaSauce()
{
return pizzaSauce;
}
}
1. Create a subclass Create a sub class that inherits everything from your base class. (For example, if Car is the base class then SportsCar could be your sub class) [1 point] Provide at least one additional attribute to your subclass [1 point] . o Create gettter/setter methods for it. Create a default constructor for the subclass, that uses super to call the base class default constructor. [1 point] . o It should set all attributes in the subclass as well as the super class to default values Create a parameterized constructor for the subclass, that uses keyword super to pass the inherited parameters to the base class. [1 point] . o It should set all attributes in the subclass as well as the super class to the values that are passed in to the constructor. Override the display0 method to print out all the instance variable values from the base class, and also from the sub class. [1 point] It should also have a method called toString and printToFile (see instructions in part 2 below) . 2. Create an Interface . Create an interface called Printable that has the following methods declared: display0, print ToFile0 and toString0 Make your subclass above implement the interface. This includes writing the bodies of all 3 methods. You should already have a display method, so you need to implement the other 2 methods [1 point] Override the toString method in the subclass in part 1 [1 point] Implement the print ToFile method in the subclass in part 1. The method should be able to append to a file, not overwrite it. [1 point] . 3. Update main method In your main method, create 2 new object using your subclass . o Create one object using the no-arg (default) constructor of your sub-class. [1 point] o Create one object using the parameterized constructor of your sub-class. [1 point o Loop (iterate) through each object calling the printToFile method. [1 point] Call the set methods to set all attribute data associated to that obiect. Create an ArrayList of all your objects, including the original ones created using the Super class and the new ones created using the Base class. [1 point]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
