Open Eclipse. Create a New -> Java project. Name it Chap7-PizzaPalaceFinal and click Finish and OK. Next, create a New -> Class. Name it Pizza and DO NOT check the first checkbox under "Which method stubs would you like to create?" and click Finish. Delete the green comment text in the file "Pizza.java" Add a comment at the top // (your name) Add another comment at the top // Exercise 7 Copy the code from your Pizza.java file from Exercise 6 and paste it into this file. Save the file. The UML has been provided with this project for reference. (ATTACHED IS A PHOTO OF THE UML)
-
-
- Open Eclipse.
- Create a New -> Java project. Name it Chap7-PizzaPalaceFinal and click Finish and OK.
- Next, create a New -> Class. Name it Pizza and DO NOT check the first checkbox under "Which method stubs would you like to create?" and click Finish.
- Delete the green comment text in the file "Pizza.java"
- Add a comment at the top // (your name)
- Add another comment at the top // Exercise 7
- Copy the code from your Pizza.java file from Exercise 6 and paste it into this file. Save the file. The UML has been provided with this project for reference. (ATTACHED IS A PHOTO OF THE UML)
-
*Hint: Code this so that it complies with the Pizza class UML provided.
Below is the Pizza.java file that you need to paste:
public class Pizza{
private String size;
private String crust;
private String toppings;
public Pizza(String size, String crust, String toppings) {
this.size = size;
this.crust = crust;
this.toppings = toppings;
}
public Pizza() {
this.size = "tbd";
this.crust = "tbd";
this.toppings = "tbd";
}
public String getSize() {
returnsize;
}
publicvoid setSize(String size) {
this.size = size;
}
public String getCrust() {
returncrust;
}
publicvoid setCrust(String crust) {
this.crust = crust;
}
public String getToppings() {
returntoppings;
}
publicvoid setToppings(String toppings) {
this.toppings = toppings;
}
publicdouble calcPrice() {
doubleprice = 0.0;
if (size.equals("1")) {
price += 12.00;
} else if (size.equals("2")) {
price += 15.00;
} else if (size.equals("3")) {
price += 18.00;
}
price += (toppings.split("\\+").length) * 2.00;
returnprice;
}
publicboolean equals(Pizza other) {
returnsize.equals(other.getSize()) &&
crust.equals(other.getCrust()) &&
toppings.equals(other.getToppings());
}
public String toString() {
returnsize + " " + crust + " Toppings=" + toppings.replace("+", " ");
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images