Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The classes you write will be to represent a variety of product types available at a supermarket. They will all have a common method to

The classes you write will be to represent a variety of product types available at a supermarket. They will all have a common method to produce multiple lines of output suitable to be included in a docket. However, depending on what type of product it is, this output will contain different sort of information. 4 For all product items, the output (for a docket) should include the following. Feel free to make the format you like. The ID of product item The name of the product item The type of the product item The price of the item The amount of the price which is a tax-component (explained next) Depending on the type of product, the following additional information should be output: If it is a Fresh Fruit item, the weight of the item (e.g., the Apple is 100 grams, the watermelon is 1200 grams). If it is a Packaged item, the quantity of units in the package (e.g., 4 eggs in the package, 20 chocolate bars in the bag), and a use-by date. The tax-component is calculated from the price of the item, and the following rates are used: For Fresh Fruit items, 0% For Packaged items, 10% of the price 2.2 Detailed Tasks 1. (3%) wCreate a class named Product to be the superclass of all products. It should have suitable constructors to aid with polymorphic behaviour and contain suitable attributes to store the information that is common to all product types (but whose values vary for each instance of that product type), and appropriate accessors. The class also contains a generic toString() method. 2. (3%) wCreate a class to represent Fresh Fruit items. It should be a subclass of the class Product. Ensure that it contains appropriate attributes to store additional information specific to fresh fruit. Ensure that there is a suitable constructor, mutators to set all values appropriately, and that there are appropriate accessors to obtain all information relevant to fresh fruit. Override toString() method so that it returns all relevant information related to the fresh fruit. 3. (3%) wCreate a class to represent Packaged items. It should be a subclass of the class made in task 1. Ensure that it contains appropriate attributes to store additional information specific to packaged items. Ensure that there is a suitable constructor, mutators to set all values appropriately, and that there are appropriate accessors to obtain all information relevant to packaged items. Override toString() method so that it returns all relevant information related to the Packaged items. 4. (15%) wCreate a driver class which will have a main method and following functionalities. Create other classes to help your program, if necessary, e.g., Transaction. Create at least 5 Fresh Fruits items and 5 packaged items and display them on the console as a product menu for customers. Ask user to select the products that they want to buy by selecting the IDs. Interaction should be ongoing and happen over the command console or GUI. User can buy multiple products in one purchase. Also, you can assume or not at most one item can be bought for each product. Each packaged item could be bought several times. Display the docket on the console which will have information about total amount due (including tax) and total tax value in each purchase/transaction. You can design and implement a simple Graphical User Interface (GUI) for the above-described customer purchasing process (self-study and investigation of java GUI is required). You can use File I/O as the product database for at least 5 Fresh Fruits items and 5 packaged items to make your program more powerful and robust. 5 5. (4%) Draw a UML class diagram for above mentioned product classes (except the driver class). Show all attributes, methods, and proper relationships between classes. Include the diagram and its description in the readme file. 6. (2%) Produce a brief readme file (with screenshots) describing about how your java project can be run (i.e., user manual) and what the program outputs look like (i.e., results/functionality demonstration), in addition to the previous project UML design requirement.

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

Statistics Informed Decisions Using Data

Authors: Michael Sullivan III

5th Edition

978-0134135373, 134133536, 134135377, 978-0134133539

More Books

Students also viewed these Programming questions