Question
Design and implement Java program as follows: There will be a Gift class with following attributes: order number (combination of letters and numbers), size (values
Design and implement Java program as follows:
There will be a Gift class with following attributes: order number (combination of letters and numbers), size (values S, M, or L), number of fruits, and price.]
There will be two child classes FruitBasket and SweetsBasket with the following additional attributes:
FruitBasket: the fee for citrus fruits based on client preference. SweetsBasket: the fee for bag of nuts based on client preference.
The Gift class hierarchy must provide the following functionality:
All attribute values can be changed after creation except order number and the values that are calculated or set by the system. Order is entered by the user. The order either begins with FB or SB and then has three digits after those letters. Must check to be sure the order number is either letter code and only three digits. When adding a new gift include in the prompt for the order number the pattern used for all orders. Price is calculated as follows: There is a flat fee of 19.99 for Small gift, 29.99 for Medium gift, and 39.99 for Large gift. Fruit basket gift has additional fee of 5.99 when it has citrus fruits. Sweets basket gift has additional fee of 4.49 when it has nuts in it. Number of fruits in a basket is as follows: Small size has 6 fruits, Medium has 9 fruits, and Large has 15 fruits. In responding to basket having citrus or nuts there is the option of Yes/No or 1 for yes/2 for no. Use the uppercase or lowercase function for the values entered. [So that the user can enter either upper or lower case for the size, reviewed the attached Use of Case Letters.docx document.] Each class must have a method to return or display the class's values to the console.
There is an ArrayList that holds all the orders generated. It is used to find the order number to change values and to display all entries.
The main () element includes the following functionality:
On creation [add to ArrayList], a gift order must be given all attribute values except price which must be calculated based on size and option for fruits or bag of nuts. Instantiation of a Gift class. Display a menu for selection. Use a switch. Order a gift. The menu should contain: Add a Gift order. The user enters the order number. The order number is checked for letters and numbers. When order number, size, and options are entered, the correct order is added to the Gift array. Change a gift [Find the appropriate id in the ArrayList and change the size and/or the added citrus or bag of nuts. Recalculate the price.] Display a single gift order. [Display horizontally with order number, type of gift, size, cost, and specifics about the order. e.g., number of fruits or with citrus or nuts.] Display all gift orders. [Display horizontally with order number, type of gift, size, cost, and specifics about the order. e.g., number of fruits or with citrus or nuts.] Exit the program. It should be considered as a driver, that is, only the minimum number of code lines are in it. Most of the coding is done in methods that are outside of the main () element. The switch should not be considered process coding - no conditionals or other detailed coding - but calls to methods in the program.
Your classes must be coded with correct encapsulation: private/protected attributes, and value validation.
There should be appropriate overloading and overriding methods.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started