Assignment 1
Be sure to type up your answers so you can submit them electronically on the
BlackBoard Connect system. You may complete this assignment individually or
with another student in the class. Make sure all your files have your full name
and student number on it.
If you worked in a pair, be sure to have both your full names and student
numbers on everything. Both of you will need to submit (the same copy) on
Blackboard Connect, even though one copy will be graded and you will both get
the same mark.
Type up your answers using a text editor as instructed in the labs.
The file format of the Java program you are to submit must be .java.
This assignment is marked out of 20 points. If you get 20/20, you will get 5%
towards the course grade.
Due Date
September 26, 2013, 11:00PM.
24 Hour Silence Policy
Due to the large class size and the potential volume of questions, we are
implementing a 24-hour silence policy. This means that any questions posted on
the discussion forum in the 24 hours immediately preceding the assignment
deadline may not get answered in time. This does not mean that we will
stop answering questions the moment the day before the deadline arrives, it just means
that we cannot promise all the questions will be answered in time, due to our
prior engagements, such as other classes and meetings we have.
For this reason, please be sure to attempt the assignment early, and try to
complete it as if it were due two days prior to the real deadline.
In any case, we will try to answer all the questions that show up on the
discussion forum. Note that questions sent to emails will not be
answered, as we want all course related material to be viewed for everyone's
benefit.
What You Are Given
You are given a partial program that helps restaurant owners receive orders for
takeout. The following files are provided for you:
Note: You cannot change what is provided in these files (except the
author's name and comments you wish to re-word). Changes will result in a lower
mark.
Question 1 [7 points]
Complete the constructor method for the TakeOut class. Recall that
each class must have a constructor method whose main responsibility is to
initialize all the class attributes. In this question, you will need to take
each attribute in the TakeOut class and assign it appropriate values.
- [1 point each] for the proper initialization of each attribute
Question 2 [8 points]
In the TakeOut class, complete the following methods:
- [2 points] makeNewCustomer()
Two things need to be done here: create a new Customer object
with the information given in the input parameters, and create a new
Order object that will be used to keep track of this customer's
orders.
- [1 point] orderEdamame()
This method is one of the five methods that is used to order a specific
menu item. In this method, the program will add edamame to the Order
object that was previously created. Which method in the Order class
will this method use to add the menu item to the Order object?
- [1 point] orderGyoza()
This method is one of the five methods that is used to order a specific
menu item. In this method, the program will add gyoza to the Order
object that was previously created. Which method in the Order class
will this method use to add the menu item to the Order object?
- [1 point] orderUniNigiri()
This method is one of the five methods that is used to order a specific
menu item. In this method, the program will add uni nigiri to the
Order object that was previously created. Which method in the
Order class will this method use to add the menu item to the
Order object?
- [1 point] orderSakeMaki()
This method is one of the five methods that is used to order a specific
menu item. In this method, the program will add sake maki to the Order
object that was previously created. Which method in the Order class
will this method use to add the menu item to the Order object?
- [1 point] orderUnagiDon()
This method is one of the five methods that is used to order a specific
menu item. In this method, the program will add unagi don to the Order
object that was previously created. Which method in the Order class
will this method use to add the menu item to the Order object?
- [1 point] completeOrder()
By reviewing the Customer class, you will notice that the
Customer object has an attribute called takeoutOrder. The
purpose of this completeOrder() method is to associate the
Order object that has been created in the TakeOut class with
the Order object in the Customer class. Which method in the
Customer class will you use to accomplish this?
If you are unclear how and when these methods are used, review the statements
inside the main() method in the TestTakeOut class.
Once you get the program working properly (that includes getting both questions
1 and 2 correct), you will see the program generate the following output:
Name: Jen
Phone: 1234567
Item: , Item: gyoza, Item: , Item: sake, Item:
Total: 10
Question 3 [5 points]
Using the TestTakeOut class provided to you, add to the
main() method statements that process the takeout in the following
scenario:
- A new customer calls in, named Ben, with phone number 987-6543
- He orders edamame and unagi don.
Follow the same steps that are used in the statements inside the
main() method, you will need to:
- [1 point] create a new customer for Ben
- [2 points] order the menu items he requested
- [1 point] complete the order
- [1 point] print the takeout information onto the screen
To get this working, you only need to call methods in the TakeOut
class. More specifically, do not call methods in any other class in the
solution for this question here.
Once you get the program working properly (that includes getting questions 1-3
correct), you will now see the program generate the following output:
Name: Jen
Phone: 1234567
Item: , Item: gyoza, Item: , Item: sake, Item:
Total: 10
Name: Ben
Phone: 9876543
Item: edamame, Item: , Item: , Item: , Item: unagi don
Total: 13
What to Submit
For this assignment, submit the following:
- TakeOut.java
- TestTakeOut.java
- Customer.java
- Order.java
- Include your full name and student ID.
If you worked in a pair, be sure to have both your full names and student
numbers on everything. Both of you will need to submit (the same copy) on
Blackboard Connect, even though one copy will be graded and you will both get
the same mark.
- List the full names of the people who helped you in this assignment
(include students and TAs if applicable), and mention what they helped you with
-- failure to do so honestly will result in a lower mark and may be reported
for academic discipline