Recent Question/Assignment

48024 Applications Programming
Assignment 1
Topics: OO design, standard patterns, lists
Objectives: This assignment supports objectives 1 - 3
Due date: 11:59pm Monday 8th of May 2017 Weight: 30%
1. Individual work
All work is individual. You may discuss ideas, approaches and problems, but you should write every line of code yourself except for code copied from the lecture notes, lecture code or lab code. You MUST NOT let another student see your solution code, and you MUST NOT look at another student’s solution code. More information about Academic Misconduct can be found at: http://www.gsu.uts.edu.au/rules/student/section-16.html
2. Specification
Luigi’s Pizzeria is a bustling pizza shop in Bondi with plans to expand its business by accepting delivery orders over the phone. The shop has already commissioned a system for handling deliveries, but they have chosen to hire you to build a system to record the orders placed over the phone.
The requirements of this system are specified in detail in this document.
The pizzeria system should record a list of customers and allows for new customers to be added to this list. When a person calls over the phone to place an order, the caller’s phone number is used to look up the customer in the list. The customer is served by recording the order. An order consists of a list of one or more pizzas, and each pizza consists of a list of ingredients, all of which can be chosen according to the customer’s preferences. There are different categories of ingredients, and the customer must include at least a certain minimum and at most a certain maximum of ingredients from each category.
The set of categories are listed below:
Category name Minimum Maximum
crust 1 1
sauce 1 1
topping 2 3
This means that every pizza must have exactly 1 choice of crust and 1 choice of sauce, and must also have at least 2 -- but no more than 3 -- toppings. The pizzeria’s kitchen offers the following ingredients in its pizzas:
Ingredient name Category Price
Thin crust $3.00
Thick crust $3.50
Tomato sauce $1.00
Barbeque sauce $1.00
Capsicum topping $0.50
Olives topping $1.50
Jalapenos topping $1.00
Beef topping $2.75
Pepperoni topping $2.50
Instead of selecting the ingredients of the pizza each time an order is placed, the customer may also choose to re-order a pizza that he or she has ordered on a past occasion. The system should be able to list the customer’s top 3 most popular pizzas and allow a selection from this list.
Finally, the total price of the order is calculated and shown, and the sale is recorded. Sales are recorded in two ways. First, the system records how many of each pizza have been sold, and second, the system records how many of each ingredient was sold. Using this information, the system is able to show a report of how much cash each ingredient brings into the shop.
An aside...
While reading the the first part of the specification, you will notice there is a lot going on.
? How many functions did you identify?
? How many classes did you identify?
? What are the fields in each class?
? How many goals did you identify?
? How many patterns did you think of that might be applicable?
This assignment will be challenging and you will probably want to manage your time well.
? How long do you think it will take you to code the functions?
? How long do you think it will take you to code each goal?
A good rule of thumb is to think of an estimate, and then multiply that number by 3 or 4! To manage your time well, you may need to figure out which parts of the assignment you can start early.
? Which parts can you start now?
? Which parts can you start in week 6?
If you complete parts in the same week that you learn the topics (while they are fresh in your mind), they will take less time to complete.
The User Interface
Below is a sample I/O trace. Not every conceivable scenario is shown below and you should submit your code to PLATE to see what specific scenarios are tested. You should also implement your solution in the same order as PLATE’s test cases so that you can receive incremental feedback and marks as you progress.
Basic usage
When the system starts, a greeting message is shown and the main menu is presented. Inputting an unrecognised command results in the help being shown:
Welcome to Luigi's Pizzeria! Pizzeria choice (a/v/s/r/x): ? a = add customer v = view customers s = serve customer r = show report x = exit
Entering ‘x’ exits the program:
Pizzeria choice (a/v/s/r/x): x
The ‘a’ option is used to add new customers:
Pizzeria choice (a/v/s/r/x): a
Phone: 99123456
Name: Ryan Heise
Pizzeria choice (a/v/s/r/x): a
Phone: 95432123
Name: Kelly Lee
Pizzeria choice (a/v/s/r/x): a
Phone: 92345678
Name: Tim Williams
The added customers can be viewed with the ‘v’ option:
Pizzeria choice (a/v/s/r/x): v
Ryan Heise: 99123456 Kelly Lee: 95432123
Tim Williams: 92345678
A new customer cannot be added with the same phone number as an existing customer:
Pizzeria choice (a/v/s/r/x): a
Phone: 92345678
An existing customer has that phone number
When a customer calls over the phone, the ‘s’ option is used to serve the customer. If the phone number is not found, an error is reported, otherwise the customer menu is presented:
Pizzeria choice (a/v/s/r/x): s
Phone: 44443333
No such customer
Pizzeria choice (a/v/s/r/x): s
Phone: 95432123
Serving Kelly Lee
Customer choice (c/p/o):
From the customer menu, an unrecognised option results in the help being shown:
Customer choice (c/p/o): ? c = create new pizza
p = select from popular past pizzas o = submit order Customer choice (c/p/o):
If the user chooses to place the order before adding any pizzas to the order, the order is discarded and the system returns to the main menu:
Customer choice (c/p/o): o
Empty order discarded
Pizzeria choice (a/v/s/r/x):
Normally, however, pizzas should first be added to the order. A new pizza can be created and added to the order with the ‘c’ option. This allows the user to input ingredient names one per line after the prompt, until entering ‘.’:
Customer choice (c/p/o): c
Creating new pizza
Ingredient(s): Thin
Thin crust pizza with no toppings and no sauce: $3.00
Ingredient(s): Tomato
Thin crust pizza with no toppings and Tomato sauce: $4.00
Ingredient(s): Jalapenos
Thin crust pizza with Jalapenos and Tomato sauce: $5.00
Ingredient(s): Beef
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
Ingredient(s): Watermelon
No ingredient matching Watermelon
Ingredient(s): .
ORDER SUMMARY
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75 Total: $7.75
Customer choice (c/p/o):
After entering ‘.’, a summary of the order so far is presented and the customer is allowed to add more pizzas to the order. In the following example, an attempt to create a pizza is made without enough ingredients in each category:
Customer choice (c/p/o): c
Creating new pizza
Ingredient(s): Thin
Thin crust pizza with no toppings and no sauce: $3.00
Ingredient(s): .
Must have at least 1 sauce
Must have at least 2 toppings
Ingredient(s):
Note that an “s” is added after the category name “topping” to form the plural form of the word, but not after the category name “sauce”. The rule is if the number is not 1, add an “s”.
The system will keep asking for ingredients since not all categories have reached their minimum required levels. Ingredients can also be matched case insensitively:
Ingredient(s): tomaTo
Thin crust pizza with no toppings and Tomato sauce: $4.00
Ingredient(s): JalAPeNos
Thin crust pizza with Jalapenos and Tomato sauce: $5.00
Ingredient(s): beef
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
Ingredients can even be found by typing in the first few letters of the ingredient name:
Ingredient(s): ol
Thin crust pizza with Jalapenos, Beef, Olives and Tomato sauce: $9.25
The same ingredient cannot be added twice, however:
Ingredient(s): beef
Already added Beef topping
And you cannot add more than the maximum ingredients for a category:
Ingredient(s): capsicum
Can only add 3 toppings
To make room for capsicum, you might remove the olives. An ingredient is removed by preceding its name (or the first few letters of it) by a minus sign:
Ingredient(s): - olives
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75 Ingredient(s): caps
Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce: $8.25 Ingredient(s): .
ORDER SUMMARY
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75 Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce: $8.25
Total: $16.00
Customer choice (c/p/o):
When the customer is ready to place the order, it is placed using the ‘o’ option. The sale is recorded and control returns back to the main menu:
Customer choice (c/p/o): o
Order submitted
Pizzeria choice (a/v/s/r/x):
From the main menu, an income report can be shown with the ‘r’ option. This reports how many of each ingredient were sold with the income it generated, and also reports the total income from all ingredients:
Pizzeria choice (a/v/s/r/x): r
2 Thin crusts sold worth $6.00
0 Thick crusts sold worth $0.00
2 Tomato sauces sold worth $2.00
0 Barbeque sauces sold worth $0.00
1 Capsicum topping sold worth $0.50
0 Olives toppings sold worth $0.00
2 Jalapenos toppings sold worth $2.00
2 Beef toppings sold worth $5.50
0 Pepperoni toppings sold worth $0.00
Income: $16.00
Pizzeria choice (a/v/s/r/x):
Note that if the number of an ingredient sold is not equal to 1, an “s” is added to its category name to convert it into the plural form.
Advanced usage
The basic features above, if you complete them all, will earn you 84% of the marks, placing you in the distinction range. The last 16% marks of the assignment are intended to be more challenging.
Another way to order a pizza is to list the ingredients in one line by separating the ingredient names by commas, as in “thick,barbeque,pepperoni,beef” as shown below:
Pizzeria choice (a/v/s/r/x): s
Phone: 92345678
Serving Tim Williams
Customer choice (c/p/o): c
Creating new pizza
Ingredient(s): thick,barbeque,pepperoni,beef
Thick crust pizza with Pepperoni, Beef and Barbeque sauce: $9.75
Ingredient(s): .
ORDER SUMMARY
Thick crust pizza with Pepperoni, Beef and Barbeque sauce: $9.75
Total: $9.75
Customer choice (c/p/o): o
Order submitted
Another way to order a pizza is to select from a previously ordered pizza, using the ‘p’ option in the customer menu. A ranked list of the most popular pizzas that the customer has previously ordered is presented, truncated to the top 3 if there are more than 3:
Pizzeria choice (a/v/s/r/x): s
Phone: 95432123
Serving Kelly Lee
Customer choice (c/p/o): p
Select from popular past pizzas:
1. (1x) Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
2. (1x) Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce:
$8.25
Selection:
Note that only Kelly Lee’s past pizzas are shown and Tim’s pizza is not included. Each line in the list has the form “RANK. (SOLDx) pizza description: $PRICE”, where SOLD indicates how many times that pizza has been sold so far. Both of the above pizzas have been sold once each so far, as indicated by 1x.
A selection is made by entering its rank:
Selection: 1
ORDER SUMMARY
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75 Total: $7.75
The $7.75 pizza is immediately recorded as having now been sold twice, which can be seen by re-entering the same selection menu:
Customer choice (c/p/o): p
Select from popular past pizzas:
1. (2x) Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
2. (1x) Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce: $8.25
If we now order 2 more of the $8.25 pizza, that pizza will be bumped up to the top of the list since the most popular pizzas are listed first:
Selection: 2
ORDER SUMMARY
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75 Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce: $8.25
Total: $16.00
Customer choice (c/p/o): p
Select from popular past pizzas:
1. (2x) Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
2. (2x) Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce:
$8.25
Selection: 2
ORDER SUMMARY
Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce: $8.25
Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce: $8.25
Total: $24.25
Customer choice (c/p/o): p
Select from popular past pizzas:
1. (3x) Thin crust pizza with Jalapenos, Beef, Capsicum and Tomato sauce:
$8.25
2. (2x) Thin crust pizza with Jalapenos, Beef and Tomato sauce: $7.75
The customer’s list of past pizzas is maintained as follows. The list starts empty when the customer is first created. When the customer creates a new pizza, the sale is recorded and that pizza is added to the end of the list. When the customer re-orders a past pizza, the sale is recorded and that pizza is moved up the list if it it’s sales is higher than any pizza above it.
Another way to order a pizza when using the ‘c’ option to create a new pizza is to input a category. Available ingredients in that category will be listed, and a selection can be made by number:
Customer choice (c/p/o): c
Creating new pizza
Ingredient(s): sauce
Select from matches below:
1. Tomato sauce
2. Barbeque sauce Selection: 2 no crust pizza with no toppings and Barbeque sauce: $1.00
Also, if inputting a partial ingredient name results in more than one match, a list of all matches is presented and a selection can be made by number:
Ingredient(s): th
Select from matches below:
1. Thin crust
2. Thick crust
Selection: 1
Thin crust pizza with no toppings and Barbeque sauce: $4.00
A partial ingredient name can even be an empty string which will match all ingredients:
Ingredient(s):
Select from matches below:
1. Thin crust
2. Thick crust
3. Tomato sauce
4. Barbeque sauce
5. Capsicum topping
6. Olives topping
7. Jalapenos topping
8. Beef topping
9. Pepperoni topping
Selection: 8
Thin crust pizza with Beef and Barbeque sauce: $6.75
Requirements
? Your design must consist of exactly the following set of classes and fields. All fields must be declared private except for the public final constants shown below. You may not add or remove classes or fields. However, you may add constructors, functions and procedures. (Copy and paste this into a new project, but be careful of copying and pasting quote characters like “ and other symbols. If your code doesn’t compile, retype these symbols manually to get the correct ASCII encoding.)
public class Pizzeria {
private LinkedList Customer customers = new LinkedList Customer ();
private Kitchen kitchen;
}
public class Customer { private String phone;
private String name;
private LinkedList Pizza ordered = new LinkedList Pizza ();
private LinkedList Pizza order = new LinkedList Pizza ();
}
public class Pizza {
private LinkedList Ingredient ingredients = new
LinkedList Ingredient ();
private int sold;
}
public class Kitchen {
public static final Category CRUST = new Category(-crust-, 1, 1);
public static final Category SAUCE = new Category(-sauce-, 1, 1);
public static final Category TOPPING = new Category(-topping-, 2, 3);
private Category[] categories = { CRUST, SAUCE, TOPPING }; private LinkedList Ingredient ingredients = new
LinkedList Ingredient ();
}
public class Ingredient {
private String name;
private double price;
private Category category;
private int sold;
}
public class Category { private String name; private int min;
private int max;
}
public class In {
private static final Scanner scanner = new Scanner(System.in);
}
? Constructor requirements:
? The Category constructor must initialise all of its fields from parameters.
? The Customer constructor must initialise the phone and name from parameters.
? The Ingredient constructor must initialise the name, price and category from parameters. The sold field is always initialised to zero.
? The Kitchen constructor has no parameters and must create and add all ingredients mentioned in the table on page 2 to the ingredients list.
? The Pizza constructor takes no parameters and does nothing (except to initialise sold to zero).
? The Pizzeria constructor has no constructor parameters and must create the kitchen and do nothing else.
? Constructor parameters must be listed in the same order as the fields.
? Field requirements:
? The Pizza’s ingredients list contains the list of ingredients added to the pizza.
? The Kitchen’s ingredients list contains the list of all available ingredients.
? The Customer’s order list contains the list of pizzas the customer has added to their current order. This list must be cleared as soon as the order is placed.
? The Customer’s ordered list contains the list of all pizzas previously ordered by this customer. As soon as an order is placed, these ordered pizzas are removed from the order list and are added to the ordered list.
? The Pizzeria’s customers list contains a list of all customers added to the shop’s system.
? toString() function requirements:
? The Category toString() function just returns the category name.
? The Ingredient toString() function returns a string in the format “Tomato sauce” where “Tomato” is the ingredient name and “sauce” is the category. ? The Customer toString() function returns a string in the format “Kelly Lee: 95432123” where “Kelly Lee” is the customer’s name and “95432123” is the customer’s phone number.
? The Pizza toString() function returns a string in the format: “CRUST pizza with TOPPINGS and SAUCE: $PRICE” where:
¦ CRUST is either “no crust” if the pizza doesn’t yet have a crust, or “Thin crust” where “Thin” is the ingredient name for the crust (it could also be “Thick”).
¦ TOPPINGS is either “no toppings” if the pizza doesn’t yet have any toppings or a list of the pizza’s topics such as “Beef, Olives, Jalapenos” where each ingredient is separated by a comma and space “, “.
¦ SAUCE is either “no sauce” if the pizza doesn’t yet have a sauce, or “Tomato sauce” where “Tomato” is the ingredient name for the sauce (it could also be “Barbeque”).
To be marked by PLATE, these three parts of the string represented by CRUST, TOPPINGS and SAUCE should be defined by 3 separate String functions:
public String crust() public String toppings()
public String sauce()
You can receive marks incrementally for each of these functions.
This is the most difficult toString() function so don’t attempt it until you get to the PLATE test case that requires it.
? Your main method must be defined in the Pizzeria class.
? You must not hardcode your program’s logic for each ingredient category. For example, you must not have if statements like if (countToppings() 2), or if (countSauces() != 1). Your code should work instead by taking ANY category and looking at it’s min and max. e.g. if (countCategory(category) category.getMin()).
? You must submit your program to PLATE and match PLATE’s output to receive marks.
Beyond this, you are free to make your own design decisions, however, a design guide will be posted to PLATE in week 6 which will offer strong recommendations on how you should design and build your solution for best results.
Take a short break, and then continue reading. What follows is important!
4. Expected workload
The time to do the assignment to a credit/distinction level has been estimated at 25 hours for a student of average ability who has completed all the tutorial and lab exercises and week 1 preparation work.
5. Online support
The Assignment 1 discussion board has been set up so that students can ask questions, and other students can reply. I will post a reply only if I think the student response was wrong, or in the case of correcting a mistake in the assignment specification.
You must not post or share Java code to the discussion board. The board is there to help you, not to provide the solution. Posting your code is academic misconduct and will reported. Each time this rule is violated, I will delete the code and post a comment of the form: “Strike 1: Posting code”. After 3 strikes, the discussion board will be deleted because it did not work.
FAQs (Frequently Asked Questions) and their answers are posted on UTSOnline in Assignments/1/faq. If you have a question, check the FAQ first; it may already be answered there. You should read the FAQ at least once before you hand in your solution, but to be safe check it every couple of days. Anything posted on the FAQ is considered to be part of the assignment specification. The FAQ will be frozen (no new entries) two days before the due date; no questions will be answered after it is frozen.
If anything about the specification is unclear or inconsistent, contact me and I will try to make it clearer by replying to you directly and posting the common questions and answers to the FAQ. This is similar to working on the job, where you ask your client if you are unsure what has to be done, but then you write all the code to do the task. Email
Ryan.Heise@uts.edu.au to ask for any clarifications or corrections to the assignment.
6. PLATE marking
Your solution is marked for correctness by PLATE (https://plate.it.uts.edu.au/) by comparing the output of your system to the output of the benchmark system. You can submit a solution to PLATE many times; I urge you to do this, so you receive credit for your work.
PLATE will test the features of your program in a certain order: Classes and fields, then constructors, then goals from basic to advanced. PLATE cannot test the more advanced goals until the basic goals are working. To receive marks, you must pass PLATE’s test cases in the order in which PLATE tests them.
Your code is marked by software, so you can get a good mark by fooling or spoofing the software. If you spoof a task worth N marks, you receive a penalty of 2*N marks.
7. Submission and return
Your solution is to be submitted to PLATE at https://plate.it.uts.edu.au/ under Applications Programming / Assessments / Assignment 1. Your provisional mark and feedback is generated immediately each time you submit to PLATE. However, analysis of spoofing, plagiarism, collusion and general cheating is done in the two weeks following the due date. If you are suspected of Academic Misconduct, I will forward your case to the Misconduct Committee and will notify you by email.
There is no scheduled late submission period. An extension of up to one week may be given by the subject coordinator before the due date; you have to supply documentary evidence of your claim. An extension CANNOT be given after the due date.
You may also apply for special consideration for reasons including unexpected health, family or work problems. More information about how to apply for special consideration can be found at http://www.sau.uts.edu.au/assessment/consideration.html.
8. Marking scheme
Task (Basic) Mark
Class and field declarations 5%
Constructors 5%
toString functions 20%
Pizzeria menu 2%
Add customer 4%
View customers 3%
Serve customer menu 3%
Create pizza from ingredient names 10%
Partial and case insensitive match 3%
Remove ingredient 4%
Check category minimums 10%
Check category maximums 6%
Check duplicate ingredients 2%
Income report 7%
Task (Advanced) Mark
List ingredients on one line 2%
Select popular pizza 10%
Select ingredient by category 2%
Select from list of partial matches 2%

Looking for answers ?


Recent Questions