public class Pizza { private String size; private int cheese; private int pepperoni; private int ham; public Pizza() { size = "small"; cheese = 0; pepperoni = 0; ham = 0; } public Pizza(String size) { this.size = size; cheese = 0; pepperoni = 0; ham = 0; } public Pizza(String size, int cheese, int pepperoni, int ham) { this.size = size; if(cheese < 0) this.cheese = 0; else this.cheese = cheese; if(pepperoni < 0) this.pepperoni = 0; else this.pepperoni = pepperoni; if(ham < 0) this.ham = 0; else this.ham = ham; } public void setSize(String newSize) { size = newSize; } public void setCheese(int newCheese) { if(newCheese < 0) cheese = 0; else cheese = newCheese; } public void setPepperoni(int newPepperoni) { if(newPepperoni < 0) pepperoni = 0; else pepperoni = newPepperoni; } public void setHam(int newHam) { if(newHam < 0) ham = 0; else ham = newHam; } public String getSize() { return size; } public int getCheese() { return cheese; } public int getPepperoni() { return pepperoni; } public int getHam() { return ham; } public double calcCost() { if(size.equals("small")) return 10 + 2 *(ham + cheese + pepperoni); else if(size.equals("medium")) return 12 + 2 *(ham + cheese + pepperoni); else return 14 + 2 *(ham + cheese + pepperoni); } public String getDescription() { return size + "pizza with" + ham + "ham toppings," + cheese + "cheese toppings, and" + pepperoni + "pepperoni toppings."; } }
it says can't find main class when I run, when I compile it is showing one error. I am so new I do not know what the error means.
It says the same error messages, not finding the main class, won't run and onepublic class TestPizza { public static void main(String[] args) { Pizza pizza1 = new Pizza(); Pizza pizza2 = new Pizza("small"); Pizza pizza3 = new Pizza("large", 3,4,5); pizza1.setSize("medium"); pizza1.setPepperoni(5); pizza2.setHam(5); pizza3.setCheese(4); System.out.println("Pizza 1's data:"); System.out.println("Size:" + pizza1.getSize()); System.out.println("Pepperoni toppings:" + pizza1.getPepperoni()); System.out.println("Cheese toppings:" + pizza1.getCheese()); System.out.println("Ham toppings:" + pizza1.getHam()); System.out.println(); System.out.println(pizza1.getDescription()); System.out.println(pizza2.getDescription()); System.out.println(pizza3.getDescription()); System.out.println(); System.out.println("Pizza 1's cost: $" + pizza1.calcCost()); System.out.println("Pizza 1's cost: $" + pizza2.calcCost()); System.out.println("Pizza 3's cost: $" + pizza3.calcCost()); } }