Purpose: The purpose of this assignment is to help you learn the Java environment and practice I/O instructions, assignment an COMP248/Winter XXXXXXXXXXTake Home Final Exam Page 1 of 6 Take Home...

The whole question is explained in the file


Purpose: The purpose of this assignment is to help you learn the Java environment and practice I/O instructions, assignment an COMP248/Winter 2020 - Take Home Final Exam Page 1 of 6 Take Home Examination Cover Sheet COURSE: COMP NUMBER: 248 SECTION(S): EC, U and W Prof: N. Acemian, Y. Yan, J. Yang Start Date: April 17, 2020, 9:00am Due Date: By April 18, 2020 9:00am What to submit: Zip the 2 source codes (the .java files only please, not the entire project) of this exam and the Take- Home Exam form as a .ZIP file (NOT .RAR) using the following naming convention: Final_studentID, where studentID is your student ID number. For example, student 123456 would submit a zip file named Final_123456.zip How to submit:  For section EC upload to the appropriate location in your eConcordia course web page.  For sections U & W, upload via your section’s Moodle course webpage. Be sure to submit the correct files! Under no circumstances will you have a second chance to submit. Recommendation:  Do not wait to the last minute to submit your exam. You have a 24-hour window during which you can submit your exam.  FYI: Do not waste time looking for a solution on the internet. This is a made up application by Dr. Nancy Acemian. There is no solution for it online. You have all the knowledge you need using the content covered in this course to program this application.  When implementing the driver (Part B) do it in chunks. Implement the application all at once might make it harder to debug. Reminder:  This exam is meant as individual work! Be aware of the University regulations concerning plagiarism described in the undergraduate Calendar. The University’s Code of Conduct located at http://www.concordia.ca/students/academic-integrity/code.html will be enforced. In cases where cheating or plagiarism is suspected, the case will be forwarded directly to the appropriate university office. http://www.concordia.ca/students/academic-integrity/code.html COMP248/Winter 2020 - Take Home Final Exam Page 2 of 6 Part A) Defining a class (15 pts) Create a class named Sundae that stores information about an ice cream sundae. It must contain the following:  Private instance variables to store the ice cream flavor (String which can have more than on word like Rockie Road), the number of scoops (int), whether it has nuts or not (boolean) and the cost (double). It also has a private static instance variable to keep track of the number of Sundae objects created (int).  Constructors: o a default constructor, that takes no arguments and initializes all instance variables to the ‘zero’ of their type and increments the static instance variable by 1. o one that takes 3 arguments (number of scoop, flavor, whether there are nuts or not) and sets all of the corresponding instance variables, calls the private method calcCost() (details below) and increments the static instance variable by 1. o a copy constructor which will also increment the static instance variable by 1.  Public accessor methods for each instance variable (both static and non-static).  Public mutator methods for each non-static instance variable except the cost instance variable.  Public void method updateCost() which calls the private method calcCost() (details below).  A private void method called calcCost() which assigns to the instance variable cost, the cost of the sundae. You charge $1.50 for each scoop of ice cream and add $1.25 if there are nuts.  A toString() method which takes no arguments and returns a String containing the value of all non-static instance variables in a descriptive message.  An equals() method which test for the equality of the content of 2 objects of type Sundae. No need to compare the cost, since if they have the same number of scoops and the same value for nuts, the cost will be the same. Recommendation: Test the methods in this class by writing a testing driver (which you are not required to submit) before moving on to Part B. Note: Do not change the specifications of the class Sundae. Please implemented as per the instructions above. COMP248/Winter 2020 - Take Home Final Exam Page 3 of 6 Part B) Using the class Sundae in a driver (20 pts) Note: In the sample outputs used to illustrate the expected behavior of your application, all user input are in green. The owner of Nancy’s Sundae Parlour needs help to keep track of her sundae orders and to generate statistics regarding the choices her customers have made. You task is to write a Java application that will: a. Display a welcome message of your choice. b. Prompt Nancy, the owner, for the maximum number of sundaes she can prepare on that day and create an empty array called todaysSundaes that will have the potential of keeping track of that many Sundae objects. c. Display a main menu with the following choices. If Nancy enters an invalid choice keep prompting her until she enters a valid choice. d. Actions to perform for each option from the Main menu. When Option 1 of the Main menu is selected:  Make sure that Nancy has not already reached the maximum number of sundaes she can make. If over the limit, tell her so.  If she is within the limit then add the sundae. What do you want to do? 1. Enter a new sundae order 2. Change information of a specific order 3. Display details for all sundaes of a specific ice cream flavor 4. Statistics on today’s sundaes 5. Quit Please enter your choice > Main menu Please enter your choice > 1 How many scoops of ice cream? 2 What flavour? bubble gum Any nuts? (y for yes anything else for no) y Please enter your choice > 1 Sorry we don't have enough ingredients to make another sundae. How many sundaes could you make today? 12 COMP248/Winter 2020 - Take Home Final Exam Page 4 of 6 When Option 2 of the Main menu is selected: Ask Nancy which sundae number she wishes to update. The sundae number is the index in the array todaysSundaes. If there is no Sundaes object at the specified index location display a message on the screen, and ask Nancy if she wishes to enter another sundae number or quit this operation and go back to the Main menu. Entering quit, returns to the Main menu. Entering anything else, prompts Nancy for a new sundae number (index location). Remember: It is possible that your array of Sundaes is not full. Just because the size of your array is length, it does not mean you have created length sundaes. If the sundae number exists, display on the screen the sundae number (which is the array index) and all of the current information for that sundae in the following format: Sundae # 0 Sundae with 3 scoops of BUBBLE GUM with nuts for a cost of: $5.75 The text in blue is generated in the driver and the text in pink is the result of the toString() method. Then ask Nancy which attribute she wishes to change by displaying the Update menu. Once Nancy has entered a correct choice, update the attribute and display again all attributes of the object in question to show that the attribute has been changed. Keep prompting Nancy for additional changes until she enters 4. Each time Nancy is prompted for a choice make sure that she enters a number from 1 to 4, otherwise keep prompting her until she enters a valid number. Don’t forget to call the updateCost() method when options 2 and 3 are selected. When option 3 is selected, it should change the value of the attribute to be the reverse. In other words, if it is false it should change it to true and vice versa. Hint: You will need to use the accessor and mutator method to accomplish this task. What would you like to change? 1. Ice cream flavour 2. Number of scoops 3. Nuts or no nuts 4. Quit Enter choice > Please enter your choice > 2 --> Valid sundae numbers are 0 to 10 Which sundae do you wish to modify? 11 Sorry no such sundae. Do you want to enter another sundae number or return to the Main menu (quit to return)? Update menu COMP248/Winter 2020 - Take Home Final Exam Page 5 of 6 Please enter your choice > 2 -->Valid sundae numbers are 0 to 10 Which sundae do you wish to modify? 1 Sundae # 1 Sundae with 4 scoops of CHOCOLATE with nuts for a cost of: $7.25 What would you like to change? 1. Ice cream flavour 2. Number of scoops 3. Nuts or no nuts 4. Quit Enter choice > 1 New flavour: Bubble gum Here is what the sundae looks like now Sundae with 4 scoops of BUBBLE GUM with nuts for a cost of: $7.25 What would you like to change? 1. Ice cream flavour 2. Number of scoops 3. Nuts or no nuts 4. Quit Enter choice > 2 How many scoops? 3 Here is what the sundae looks like now Sundae with 3 scoops of BUBBLE GUM with nuts for a cost of: $5.75 What
Apr 18, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here