Cosc 215 - Program #2

Pizza All Around

Due: 2/12/08
Points: 50

The second programming assignment concerns an ordering system for a pizzeria. The pizzeria offers only three kinds of menu items: Pizzas, calzones, and strombolis:

Pizza
A flat, open-faced baked pie of Italian origin, consisting of a thin layer of bread dough topped with spiced tomato sauce and cheese, often garnished with anchovies, sausage slices, mushrooms, etc. (from dictionary.com).
Calzone
A turnover made of pizza dough, usually containing cheese, prosciutto, and herbs or garlic and either baked or fried. (from dictionary.com).
Stromboli
A type of turnover filled with various cheeses, pepperoni, and Italian meats or vegetables. (from wikipedia).

The program should be able to create an order, make modifications to an order, and print out the order. To accomplish this, you will need to create a Order class with the appropriate methods. An order will consist of a list of items that have been ordered. You may assume (but do not have to assume) that an order consists of at most fifty (50) items.

Pizzas always come with a crust, tomato sauce, and cheese (no white pizzas here), and may be customized with different toppings, given below. Pizzas come in three sizes: small, medium, and large. A small pizza costs $6.59 for a plain pizza, plus $1.19 per topping (however, some toppings count as double toppings and cost twice as much). A medium plain pizza costs $8.59 and each additional topping is $1.79. A large pizza costs $9.59 and each additional topping is $1.99. You may assume that a pizza may have at most ten (10) toppings, and it is possible to order a topping twice, e.g., double pepperoni, on a pizza.

A calzone also comes with tomato sauce and cheese, and may have additional toppings added. There are only two sizes of calzones, small and large. A small calzone costs $5.99 and each topping is $1.29, and a large calzone costs $7.99 and each additional topping is $1.49. A calzone may have up to eight (8) toppings.

A stromboli has only one size and can have at most four (4) toppings. The price is always $6.50, no matter the number of toppings.

The toppings are: pepperoni, sausage, anchovies, ham, meatballs, steak, salami, capicola, chicken, mushrooms, green peppers, tomatoes, onions, black olives, broccoli, and red peppers. Steak, chicken, broccoli, and red peppers count as double toppings (cost twice the price of the others).


The Order class will interact with the customer (the main method). An order will consist of a number of menu items, each of which may be customized by size and toppings. One of the menu items in the order will be denoted as the "current" item, and all changes will be made to that item. The items in the order will be numbered, starting at 1, and the customer may refer to an existing item by its number. The Order class should have the following methods:

addItem(String)
Adds a new item to the order. The new item becomes the last item in the order. String will be one of "Pizza", "Calzone", or "Stromboli". The new item will become the current item.
setSize(String)
Sets the size of the current item to the size indicated by String. An error message should be printed out if the size is not appropriate for the item, or if the item is a stromboli which has only one size.
addTopping(String)
Adds the topping given by String to the current item in the order. The same topping may be added more than once, i.e., double pepperoni. A message should be printed if too many toppings have been added.
deleteTopping(String)
The topping with the name String is deleted from the current item. An error message should be printed if no such topping was on the item.
deleteItem(int)
Item number int is deleted from the order. All items after it in the order will be renumbered to one less number, i.e., item 7 becomes item 6, when item 5 is deleted. If the deleted item is the current item, then there is no longer any current item, and any attempts to modify the current item will cause an error message to be issued, until the current item is set again.
makeCurrent(int)
Item number int becomes the current item, and then may be modified. If int is not a valid item in the order, an error message should be printed.
print()
Prints out the entire order. Each item, along with its number, is printed out in detail: the size, if more than one size is available, the toppings, and the price. The total price for the order (excluding tax and delivery charges) should also be printed at the end.

There is no need for the main() method to read input from the user. The program may construct the order directly in code. Your program must use classes, and a class hierarchy, in a meaningful way, i.e., use base class and derived class, and inheritance to share common code. The Order class should do most of its work by passing messages to other classes. The main method should exercise all of the constructors and methods of the Order class. One hint: look at using the java Vector class.


If you have questions or comments, email me at simon@mathcs.duq.edu