Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 2: Inheritance and Encapsulation Before attempting this project, be sure you have completed all the reading assignments, nongraded exercises, discussions, and assignments to date.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Assignment 2: Inheritance and Encapsulation Before attempting this project, be sure you have completed all the reading assignments, nongraded exercises, discussions, and assignments to date. Design and implement Java program as follows: (1) There will be a Snack class with following attributes: id (combination of numbers and letters), size (values S, M, or L), and price (2) There will be two child classes FmirSnack and SalnzSnac-k with the following additional attributes: o FmitSnac-k: It includes citrus fruit indication (value of this variable of is true or false) 0 SalWSnack: It includes nut snack indication (value of this variable of is true or false) (3) The Snack class hierarchy must provide the following functionality: o On creation, a snack instance must be given all attribute values except its price, which must be calculated 0 Price is calculated as follows: 0 There is a at fee of $19.99 for S snack, $29.99 for M snack, and $39.99 for L snack. o FruitSnack has an additional fee of $5.99 when it has a citrus 'uit. Please add only a single citrus fruit, and no preventing coding is required to limit adding more than one. o SaltySnack has an additional fee of $4.50 when it has a nut snack. Please add only a single nut snack no preventing coding is required to limit adding more than one. 0 Each class must have a method to return or display the class's values to the console (4) Implement OrderSystem class with main method with following functionality: 0 Order a snack and after ordering it will display the snack type, its size, id and price 0 Exit program (5) Your classes must be coded with correct encapsulation: private/protected attributes, get methods, and set methods (5) Your classes must be coded with correct encapsulation: private/protected attributes, get methods, and set methods (6) There should be appropriate overloading and overriding methods (7) OrderSystem should take advantage of the inheritance properties (e. g., use Snack variable regardless which snack instance as appropriate) (8) The prices for S, M, L, citrus fruit, nut snack can be hard coded in the program. Test Scenario 1: MENU 1: Order a Snack 2: Exit program Enter your selection: 2 Thank you for using the program. Goodbye! Test Scenario 2: MENU 1: Order a Snack 2: Exit program Enter your selection: 1 Do you want Fruit Snack (1) or Salty Snack (2) : 1 What size do you want: S, M, or L: S Do you want citrus fruit included? true/false: true You have chosen snack type = Fruit Snack, of type = S, id = ? and price = ? Test Scenario 3: MENU 1: Order a Snack 2: Exit program Enter your selection: 1 Do you want Fruit Snack (1) or Salty Snack (2) : 1 What size do you want: S, M, or L: M Do you want citrus fruit included? true/false: false You have chosen snack type = Fruit Snack, of type = M, id = ? and price = ? Test Scenario 4: MENU 1: Order a Snack 2: Exit program Enter your selection: 1 Do you want Fruit Snack (1) or Salty Snack (2) : 1 What size do you want: S, M, or L: L Do you want citrus fruit included? true/false: false You have chosen snack type = Fruit Snack, of type = L, id = ? and price = ? Test Scenario 5:Test Scenario 5: MENU 1: Order a Snack 2: Exit program Enter your selection: 1 Do you want Fruit Snack (1) or Salty Snack (2): 2 What size do you want: S, M, or L: S Do you want nut snack included? true/false: true You have chosen snack type = Salty Snack, of type = 5, id = ? and price = ? 'TestScenarh16: MENU 1: Order a Snack 2: Exit program Enter your selection: 1 Do you want Fruit Snack (1) or Salty Snack (2): 2 What size do you want: S, M, or L: M Do you want nut snack included? true/false: False You have chosen snack type = Salty Snack, of type = M, and id = P and price =

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions