SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,kenrick Mock
Chapter:
Arrays
Exercise:
Programming Projects
Question:15 | ISBN:9780132830317 | Edition: 5

Question

Programming Project 4.12 asked you to create a PizzaOrder class that stores an order consisting of up to three pizzas. Modify the class to store the pizzas using an array. This will allow the class to include an arbitrary number of pizzas in the order instead of a maximum of three. The setNumPizzas method can be used to create an array of the appropriate size. The array structure allows you to eliminate the methods setPizza1 , setPizza2 , and setPizza3 and replace them with a single method, setPizza(int index , Pizza newPizza ). Include appropriate tests to determine if the new PizzaOrder class is working correctly.


TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Modify the PizzaOrder class from Programming Project 4.12 from the text book.

Modified code:

private String size;
private int cheese;
private int pepperoni;
private int ham;
public Pizza(String size)
public Pizza(String size, int cheese,
         int pepperoni, int ham)
public Pizza(Pizza aPizza)
public void setSize(String newSize)
public void setCheese(int newCheese)
public void setPepperoni(int newPepperoni)
public void setHam(int newHam)
public double calcCost()
public String getDescription()

 

0 0

Discussions

Post the discussion to improve the above solution.