Coding Assignment - Fruit Stand
Coding Assignment - Fruit Stand
Objective:
Create a comprehensive program that emulates a fruit stand. The program should initiate by prompting the user to
input the type of fruit they would like to purchase. After, the user selects the type of fruit they would like to
purchase, the program will prompt the user to enter the amount of the fruit item that they would like to purchase.
After, the amount is entered, the program will prompt the user if they would like to continue shopping. If the user
chooses to continue the program will continue to run until the user chooses to stop shopping. Upon completion of
shopping, the program should display the fruit with their amounts and total price of the purchase.
Requirements:
1. Class – Fruit
o Create an abstract class named Fruit.
o Define at least three fields to describe the fruit with the appropriate access modifiers (e.g. color,
type, etc.)
o Define a price variable with the appropriate access modifier
Constructors:
o Implement a copy constructor that takes a Vehicle object as a parameter and initializes the fields
accordingly.
Methods:
o Define necessary accessor and mutator methods.
o Define at least three abstract methods for this class
o Define another abstract method to calculate the total price of the fruit. Add a 7% sales tax to
each purchase
2. Fruit Classes – Create a least two other classes that represent a piece of fruit (e.g. orange, kiwi). These
classes will inherit the Fruit class – These classes must be implemented in different files
o Class names should reflect the type of fruit that is being implemented
Methods:
o Implement all abstract methods (override the method in the Fruit class to calculate the total
price of the fruit
o Override the toString method to reflect each specific fruit details
3. Class - Demo
o Demonstrate the functionality of the fruit stand in a separate class called Demo.
o Create necessary objects from Fruit classes to allow users to shop
4. Input Validation
o Ensure users can input case-insensitive values to quit the program.
o Validate menu options to ensure that only valid selections are accepted, catching any invalid
inputs.
5. Output
o Display fruit stand information in a user-friendly format
o Format prices to include dollar signs, two decimal places, and commas
o Display fruit price and total price of purchase after the user finishes shopping
6. Implementation Details
o Utilize concepts from chapters 1-11 only.
o Follow the program rubric closely.
7. Naming Convention
o Name the project fruit-stand.zip.
o Export your project as a zip file.
Sample Runs (Please use your own fruit classes. The fruits below are for example):
Run 1 – Purchase one fruit item
---------------------------------------------
Welcome to the Fruit Stand!
We sell Red Apples, Green Apples, and Bananas
---------------------------------------------
What fruit would you like to purchase? Banana