COMP1040 Assignment 2
This document describes Assignment 2 for Programming Fundamentals. The assignment will require you to
write classes to represent a Pizza Shop. You will be required to create an inheritance hierarchy for Food
used as ingredients in a Pizza and to write classes for operating a Pizza Shop. Your ingredients and your
menu of Pizzas should be read in from text files. You must write receipts for all ordered Pizzas to a text file.
The program will require a text-based user interface that allows the user to select, modify and order Pizzas.
This document describes the classes, fields and methods required. It describes the format of the text files.
It also shows examples of the textual user interface which you will need to replicate.
This assignment is an individual task that will require an individual submission. You will be required to
submit this project in week 12 of the study period. In the case that you do not fully understand the
assignment, please ask your lecturer.
The ingredients package contains classes that allow us to create a Pizza and add toppings onto it.
The package contains a class called FoodSet that contains a resizable array of Foods. The FoodSet must
ensure that there is only one copy of each Food. If its array fills up, it will automatically double in size.
The Food class contains a name and price. This class will be constructed to represent various pizza
toppings like tomato sauce, cheese, ham, and pineapple. Any Food item added to a Pizza that was not part
of the original toppings will add its price to the Pizza.
PizzaBase will be derived from Food. It represents the round bread that the rest of the toppings will go on.
It will contain the method setSize that takes a string ("small", "medium", or "large") and sets the diameter
and price accordingly. There will be methods for calculating the square inches and calculating the price per
. These methods will be necessary to change the price for PizzaBases of different sizes.
Pizza is also derived from Food and contains a PizzaBase and two FoodSets: toppings and
originalToppings. Many pizza shops allow you to customize your order by removing ingredients you do not
want or by adding new ingredients for a fee. Our program will do the same. There will be methods for
adding and removing toppings, and for changing the PizzaBase and size. The getPrice() method must add
a fee for any Food that is in toppings that was not in originalToppings.
The pizzashop package contains classes that allow us to open and operate a pizza shop. It will read
ingredients and the pizza menu from file, allow the user to order and customize pizzas using a text-based
interface, and save receipts for orders to a file.
PizzaMenu is derived from FoodSet and uses polymorphism to ensure you may only add and get Pizzas
The PizzaShop will need to create a FoodSet of ingredients and a PizzaMenu of Pizzas using information
read from a file. It allows the user to use keyboard input to select a Pizza from the PizzaMenu and to
customize it, adding or removing toppings, or changing the base or size. The user may order any number of
Pizzas in this way before exiting the program. The receipt for each order will be written to a file.
You have been provided with a folder called files containing a folder called receipts and two files: menu.txt
The ingredients file contains information which will be used to construct the various pizza ingredients. Each
line represents the name and price for one ingredient. For Food items the format is "name $price".
PizzaBases are prepended with the string "base:" such as "base: deep pan $8". In this case, name is "deep
pan" and price is 8.0. The file may contain the following:
base: deep pan $8
base: thin crust $8
base: cheese crust $12
tomato sauce $0
bbq sauce $0
sweet chilli sauce $0.5
chedder cheese $1
mozzarella cheese $1
fetta cheese $1
Your PizzaShop class will need to implement a method called loadIngredients() that reads the file and for
each line extracts the name and price. If it starts with the word "base: ", it will construct a PizzaBase,
otherwise it will construct a Food with the extracted information. The Food will then be added to the
PizzaShop's ingredients FoodSet.
The menu file contains the recipe for making all of the pizzas that the pizza shop offers. Each line is in the
format "pizza name $price ingredient name 1, ingredient name 2". The file may contain the following:
Margarita Pizza $12 tomato sauce, mozzarella cheese, chedder cheese
Hawaiian Pizza $12 tomato sauce, mozzarella cheese, ham, pineapple
Meat Lovers Pizza $12 bbq sauce, mozzarella cheese, ham, salami, onion
Supreme Pizza $12 tomato sauce, mozzarella cheese, ham, mushrooms, capsicum, salami,
Vegetarian Pizza $12 tomato sauce, fetta cheese, capsicum, pineapple, mushrooms,
BBQ Chicken Pizza $14 bbq sauce, mozzarella cheese, chicken, onion
Spicy Seafood Pizza $14 sweet chilli sauce, mozzarella cheese, prawns, anchovies,
jalapenos, capsicum, onion
Chicken and Prawn Pizza $16 sweet chilli sauce, fetta cheese, chicken, prawns, spinach
3 of 17
The PizzaShop class must implement a method called loadMenu() that reads the menu file and constructs
a Pizza using information extracted from each line. To construct a Pizza you will need the name, price, a
FoodSet of toppings, a size, and a pizza base. You can assume that all Pizzas in the file are on a "large",
"thin crust", PizzaBase. Each topping should be accessed from the FoodSet created using the
loadIngredients() method. These toppings should go into a new FoodSet and used to construct the Pizza.
英国作业代写,✔美国代考,【assignment代写】,business代写The Pizza will then be added to the PizzaShop's PizzaMenu.