Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A sigament 2: Inheritance and Encapsulation Before attempting this project, be sure you have completed all the reading assignments, non-graded exercises, discussions, and assignments to

image text in transcribed
image text in transcribed
image text in transcribed
A sigament 2: Inheritance and Encapsulation Before attempting this project, be sure you have completed all the reading assignments, non-graded exercises, discussions, and assignments to date. Design and implement Java program as follows: (1) There will be a Snock class with following attributes id (combination of mumbers and letters). size (values S,M, or L ), and price (2) There will be two child classes FruilSrack and Saitysnack with the folloving adfitional atuributes: Fruik Snod: It includes citrus fruit indication (value of this variable of as true or fise) SalyShod: It includes nut snack indication (vake of the variable of is true or fake) (3) The Snack class hierarchy must provide the following functionality? - On creation, a snack instance must be given all attribate valucs except its price, which nust be calculated - Price is calcubted as follows: There is a flat fee of 519.99 for S snack, 59999 for M sack and S39.99 for L stack: Fruitsnack has an additional fee of 5599 whica it has a cutras fruit. Pleuse add only a single citrus fruit, and ao preventing coding is tequered to linit adding note than one. Salty Snack has an addtional fee of $4.50 when it has a reit snack. Pkase add only a single nut snack no preventing coding is required to limir alding more than one. - Each class must have a method to return or display the class's values to the console (4) Implement OrderSystem chss with main method with following functionelity: Order a snack and after ordering it will display the snack type its sire, id and price Exit program (5) Your classes must be coded with correct encapsulation peivate protectod at tnbutes, get methods. and set methods (6) There should be appropciate overloading and overriding methods (7) OrderSystem should take advantage of the inheritance propertics (e.g. use Snack variable regardless which snack instance as appropriate) (8) The prices for S. M, L, citnes fruit, nut snack can be hard codod in the program. Style and Documentation: Make sure your Java program is using the recommended style such as: - Iavadoc comment with your name as aubbor, date, and brief purpose of the program - Comments for varibles and blocis of code to deicribe major functionality - Mcaningfid variable names and prompts - Class names are writicn in upper Cane Case - Constants are written in All Capitak - Use proper spacing and empty lines to make code human readable Capture execution: You must capture the sereen shots of running the code for different test seenarios and inclade the screen shots of the test runs in the documentation. The following is a sample of a few of the test scenarios for you to follow, and you can add more. Any variation with the menu shown below, or any change in the language of the display or the display format for the menu for ajustified reason is accepted. In the test seenarios the symbol of question mark (?) means that is the value yourprogram will compute. For example, your prograns will display the value of id, that is noted as? Your program will compute the value of the price and display it, and that is also indicated as 2. Test Scenario If MENU 1. Onder a snack 2: Exit progran Enter your selection: 2 Thank you for using the progran. Coodbyel Tet Scenario 24. MEN 1: Order a Snack 2: Exit progran Enter your selection: 1 Do you want. Fruit Snack (1) or 5a1 ty 5 nack (2): 1 What size do you want: 5 , M, or li 5 Do you want citrus fruit Included? true/false: true You have chosen snack type = Fruit 5 nack, of type =5, id = Z and price a ? Test Scenario 3t MEMU 1: Order a Snack 2: Exit progran Enter your selection: 1 Do you want Frult Snack (1) or Salty Snack (2): 1 What size do you want: 5,M, or L: M. Do you want citrus frult Included? true/false: false You have chosen snack type = Fruit Snack, of type =M, ld =? and price an Tet Scenario 4: MEWU 1: Order a. Snack 2: Exit progran Enter your selection: 1 Do you want Fruit 5 nack (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 - Frult Snack, of type 1, id =7 and price =7 ? Test Scenario 5: Meral 1: Order a Snack 2t Exit progran Enter your selection: 1 Do you want Fruit Snack (1) or Salty Snack (2): 2 What size do you want: 5,1 , or t15 Do you want nut snack included? true/false: true You have chosen snack type * Salty Snack, of type =5,1d=7 and price = ? Test Scenario 6: MENU 1: Order a Snack 2: Exit program Enter your selection: 1 Do you want Fruit Snack (1) on Salty Snack (2): 2 What size do you want: S, M, or L: M Do you want nut snack included? true/fa1se: false You have chosen snack type = salty Snack, of type =M, and 1d= ? and price it? Submission Requirements: Deliverables include Java program (java files) and a single documentation including the screen shots of the test runs either as a Mierosoft Word file, or as a PDF. The Java and Word/PDF files should be named appropriately for the assignment (as indicated in the Submission Requirements document, The word (or PDF) document should include screen captures showing the successful compiling and running of each of the test scenario. Test scenarios should include all required functionality of the program. Each screen capture should be properly labeled clearly indicated what the screen capture represents. Do not submit the screen shots of the test nins separately as image filcs but incladd (embed) them in the document and finally submit a single document

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_2

Step: 3

blur-text-image_3

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

9. Make sure goals are internalized and accepted by the athlete.

Answered: 1 week ago