I keep getting an error with this, and i dont know why? Heres the error symbol:
ID: 660981 • Letter: I
Question
I keep getting an error with this, and i dont know why?
Heres the error
symbol: class SpecialOne
location: class CustomerInterface
C:UsersTaylerDesktopCS111Splinters PizzasrcCustomerInterface.java:84: error: cannot find symbol
SpecialOne pie = new SpecialOne("Meatlovers","Deep-Dish", "Medium", "Marinara", "pepperoni, sausage, bacon, canadaon bacon", "mozzarella",15.00);
^
symbol: class SpecialOne
location: class CustomerInterface
C:UsersTaylerDesktopCS111Splinters PizzasrcRegularPie.java:147: error: no suitable constructor found for RegularPie(RegularPie.SpecialOne)
super(originalObject);
^
constructor RegularPie.RegularPie(String,String,String,String,String) is not applicable
(actual and formal argument lists differ in length)
constructor RegularPie.RegularPie() is not applicable
(actual and formal argument lists differ in length)
3 errors
This is in my main --->
SpecialOne pie = new SpecialOne("Meatlovers","Deep-Dish", "Medium", "Marinara", "pepperoni, sausage, bacon, canadaon bacon", "mozzarella",15.00);
public class RegularPie
{
protected String name;
protected String size;
protected String crust;
protected String sauce;
protected String cheese;
public RegularPie()
{
name = "regular pie";
crust = "Hand- Tossed";
size = "medium";
sauce = "marinara";
cheese = "mozzarella";
}
public RegularPie(String theName, String theCrust, String theSize, String theSauce, String theCheese)
{
if(theName ==null ||theCrust ==null ||theSize ==null ||theSauce ==null ||theCheese ==null)
{
System.out.println("Pizza not created");
System.exit(0);
}
name = theName;
crust = theCrust;
size = theSize;
sauce = theSauce;
cheese = theCheese;
}
public String getName()
{
return name;
}
public String getCrust()
{
return crust;
}
public String getSize()
{
return size;
}
public String getSauce()
{
return sauce;
}
public String getCheese()
{
return cheese;
}
public void setName(String newName)
{
if (newName == null)
{
System.out.println("Error with name");
System.exit(0);
}
else
{
name = newName;
}
}
public void setCrust(String newCrust)
{
if (newCrust == null)
{
System.out.println("Error with crust");
System.exit(0);
}
else
{
crust = newCrust;
}
}
public void setSize(String newSize)
{
if (newSize == null)
{
System.out.println("Error with size");
System.exit(0);
}
else
{
size = newSize;
}
}
public void setSauce(String newSauce)
{
if (newSauce == null)
{
System.out.println("Error with suace");
System.exit(0);
}
else
{
sauce = newSauce;
}
}
public void setCheese(String newCheese)
{
if (newCheese == null)
{
System.out.println("Error with topping");
System.exit(0);
}
else
{
cheese = newCheese;
}
}
public String toString()
{
return("You order the " + name + " pizza, that has a " + crust + " crust, a standard " + size + " size, a " + sauce +" sauce, and a " + cheese + " topping.");
}
public boolean equals(RegularPie otherRegularPie)
{
return (name.equals(otherRegularPie.name)&&crust.equals(otherRegularPie.crust)&&size.equals(otherRegularPie.size)&&sauce.equals(otherRegularPie.sauce)&&cheese.equals(otherRegularPie.cheese));
}
public class SpecialOne extends RegularPie
{
private String topping;
private double price;
public SpecialOne()
{
super();
topping = "";
price = 0;
}
public SpecialOne(String theName, String theCrust, String theSize, String theSauce, String theCheese, String theTopping, Double thePrice)
{
super(theName, theCrust, theSize, theSauce, theCheese);
topping = theTopping;
price = thePrice;
}
public SpecialOne(SpecialOne originalObject)
{
super(originalObject);
topping = originalObject.topping;
price = originalObject.price;
}
public String getTopping()
{
return topping;
}
public double getPrice()
{
return price;
}
public void setTopping(String newTopping)
{
topping = newTopping;
}
public void setPrice(Double newPrice)
{
price = newPrice;
}
public String toString()
{
return ("The name of the pizza is"+getName()+" the name of crust is "+getCrust() +" the size of the pizza is "+getSize()+" the sauce of the pizza is "+getSauce()+" the toppings on the pizza are "+getTopping()+" the cheese is "+getCheese()+" the price is "+getPrice()+"");
}
public boolean equals(SpecialOne other)
{
return(name.equals(other.name)&&crust.equals(other.crust)&&size.equals(other.size)&&sauce.equals(other.sauce)&&cheese.equals(other.cheese)&&topping.equals(other.topping)&&price==other.price);
}
}
}
Explanation / Answer
//Modifications and driver program are highlighted in bold letters.
//RegularPie.java
public class RegularPie
{
protected String name;
protected String size;
protected String crust;
protected String sauce;
protected String cheese;
public RegularPie()
{
name = "regular pie";
crust = "Hand- Tossed";
size = "medium";
sauce = "marinara";
cheese = "mozzarella";
}
public RegularPie(String theName, String theCrust,
String theSize, String theSauce, String theCheese)
{
if(theName ==null ||theCrust ==null ||theSize ==null ||theSauce ==null ||theCheese ==null)
{
System.out.println("Pizza not created");
System.exit(0);
}
name = theName;
crust = theCrust;
size = theSize;
sauce = theSauce;
cheese = theCheese;
}
public String getName()
{
return name;
}
public String getCrust()
{
return crust;
}
public String getSize()
{
return size;
}
public String getSauce()
{
return sauce;
}
public String getCheese()
{
return cheese;
}
public void setName(String newName)
{
if (newName == null)
{
System.out.println("Error with name");
System.exit(0);
}
else
{
name = newName;
}
}
public void setCrust(String newCrust)
{
if (newCrust == null)
{
System.out.println("Error with crust");
System.exit(0);
}
else
{
crust = newCrust;
}
}
public void setSize(String newSize)
{
if (newSize == null)
{
System.out.println("Error with size");
System.exit(0);
}
else
{
size = newSize;
}
}
public void setSauce(String newSauce)
{
if (newSauce == null)
{
System.out.println("Error with suace");
System.exit(0);
}
else
{
sauce = newSauce;
}
}
public void setCheese(String newCheese)
{
if (newCheese == null)
{
System.out.println("Error with topping");
System.exit(0);
}
else
{
cheese = newCheese;
}
}
public String toString()
{
return("You order the " + name + " pizza, that has a " +
crust + " crust, a standard " + size +
" size, a " + sauce +
" sauce, and a " + cheese + " topping.");
}
public boolean equals(RegularPie otherRegularPie)
{
return (name.equals(otherRegularPie.name)&&crust.equals(otherRegularPie.crust)&&size.equals(otherRegularPie.size)&&sauce.equals(otherRegularPie.sauce)&&cheese.equals(otherRegularPie.cheese));
}
}
------------------------------------------------------------------
//SpecialOne.java
//The class inherit the public members from the super class RegularPie
public class SpecialOne extends RegularPie
{
private String topping;
private double price;
public SpecialOne()
{
super();
topping = "";
price = 0;
}
public SpecialOne(String theName, String theCrust,
String theSize, String theSauce, String theCheese,
String theTopping, Double thePrice)
{
super(theName, theCrust, theSize, theSauce, theCheese);
topping = theTopping;
price = thePrice;
}
/*The SpecialOne constructor that takes input SpecialOne object is
incorrect.Remove this constructor*/
/*Since passing the same class object to the super class
the member variables of the this SpecialOne class should
be in that super class to assign in RegualPie class
But the private members of the class SpecialOne is in
the current class to set and get . Only values
that are need to set from this class are passed to the super class
RegualrPie values using super method calling.
These values are passed to the super class
and set to the values in the super class RegularPie member variables.*/
/*public SpecialOne(SpecialOne originalObject)
{
super(originalObject);
topping = originalObject.topping;
price = originalObject.price;
}*/
public String getTopping()
{
return topping;
}
public double getPrice()
{
return price;
}
public void setTopping(String newTopping)
{
topping = newTopping;
}
public void setPrice(Double newPrice)
{
price = newPrice;
}
public String toString()
{
return ("The name of the pizza is "+getName()+
" The name of crust is "+getCrust() +
" The size of the pizza is "+getSize()+
" The sauce of the pizza is "+getSauce()+
" The toppings on the pizza are "+getTopping()+
" The cheese is "+getCheese()+
" The price is "+getPrice()+"");
}
public boolean equals(SpecialOne other)
{
return(name.equals(other.name)&&
crust.equals(other.crust)
&&size.equals(other.size)
&&sauce.equals(other.sauce)
&&cheese.equals(other.cheese)
&&topping.equals(other.topping)
&&price==other.price);
}
}
------------------------------------------------------------------
//Driver proram to test the class SpecialOne constructor and equality method.
//DriverProgram.java
public class DriverProgram
{
public static void main(String[] args)
{
//create an instance of class SpecialOne
SpecialOne pie = new SpecialOne("Meatlovers",
"Deep-Dish",
"Medium",
"Marinara",
"pepperoni, sausage, bacon, canadaon bacon",
"mozzarella",15.00);
System.out.println(pie.toString());
//create an instance of class SpecialOne
SpecialOne otherPie = new SpecialOne("Meatlovers",
"Deep-Dish",
"Medium",
"Marinara",
"pepperoni, sausage, bacon, canadaon bacon",
"mozzarella",15.00);
//checking equality of two objects of SpecialOne class
//calling equals method that returns true if pie object
//contains the same values as otherPie object
//otherwise returns false.
if(pie.equals(otherPie))
System.out.println("Both objects are equal");
else
System.out.println("Both objects are not equal");
}
}
------------------------------------------------------------------
sample output:
The name of the pizza is Meatlovers
The name of crust is Deep-Dish
The size of the pizza is Medium
The sauce of the pizza is Marinara
The toppings on the pizza are mozzarella
The cheese is pepperoni, sausage, bacon, canadaon bacon
The price is 15.0
Both objects are equal
Hope this helps you