Complete a read me of what each class does in this assignment. (DUE SEPT 12TH 2022!!!!) TODAY
COP-3337 Programming II
Programming Assignment 1: Designing Classes, Inheritance, & Polymorphism
Florida International University
1 Problem Specification
For this programming assignment, you will be completing the implementation of a java program for the checkout system of a grocery store which sells rice by pound, eggs by the dozen, baguette, and flavored baguette (baguette flavored with chocolate, vanilla, garlic, caramel, etc).
To do this, you will implement an inheritance hierarchy of classes derived from an Item superclass:
‹ The Rice, Egg, and Baguette classes will be derived from the Item class.
‹ The FlavoredBaguette class will be derived from the Baguette class.
You will also write a Checkout class which maintains a list of Items.
1.1 The Item Class
The Item class is a superclass from which specific types of Items can be derived. It contains only one data member, a name. It also defines a number of methods. All of the Item class methods are defined in a generic way in the file, Item.java, which is uploaded along with some other files in toe form of an archive named “related files.zip” on Canvas. The getCost() method of Item class is a method that merely returns zero as the way of determining the costs varies based on the type of item. Therefore, this method needs to be overridden in every subclass of class Item. Moreover, Tax amounts should be rounded to the nearest cent. For example, the tax on a food item with the cost of 199 cents with a tax rate of 2.0% should be 4 cents.
Do NOT change the Item.java file! Your code must work with this class as it is provided.
1.2 The GroceryStore Class
The GroceryStore class is available on Canvas in the file named GroceryStore.java. It con- tains some constant instant fields such as the tax rate as well the name of the store, the maximum length of the string representing an item name and the maximum number of characters allowed to display the costs of items on the receipt. Your code should use these
1
constants to generate the receipt appropriately. The GroceryStore class also contains the cents2dollarsAndCents method which takes an integer number of cents and returns it as a String formatted in dollars and cents. For example, 105 cents would be returned as “1.05”.
Do NOT change the GroceryStore.java file. Your code must work with this class as it is provided.
1.3 The Derived Classes
All of the classes which are derived from the Item class must define a constructor. Please see the provided TestCheckout class,TestCheckout.java , to determine the parameters for the various constructors. Each derived class should be implemented by creating a file with the correct name; e.g. Rice.java.
‹ The Rice class should be derived from the Item class. A Rice item has a weight and a price per pound which are used to determine its cost. For example, 2.30 lbs.of rice @ .89 /lb. = 205 cents. The cost should be rounded to the nearest cent.
‹ The Egg class should be derived from the Item class. An Egg item has a number and a price per dozen which are used to determine its cost. For example, 4 eggs @ 399 cents /dz. = 133 cents. The cost should be rounded to the nearest cent.
‹ The Baguette class should be derived from the Item class. A Baguette item simply has a cost.
‹ The FlavoredBaguette class should be derived from the Baguette class. The cost of a FlavoredBaguette is the cost of the Baguette plus the cost of its flavor.
1.4 The Checkout Class
The Checkout class provides methods to enter grocery items into the cash register, clear the cash register, get the number of items, get the total cost of the items (before tax), get the total tax for the items, and get a String representing a receipt for the grocery items (you may override the toString method of Object class). The Checkout class needs to store a list of Items. The total tax should be rounded to the nearest cent.
1.5 Testing
A simple test-driver, TestCheckout.java, along with its expected output, is available to help you test your class implementations. You can add additional tests to the driver to test your code extensively.
2 Submissions
You need to submit a .zip file compressing the following files:
‹ Java source file(s) of your program (.java files only).
2
‹ readme.txt explaining what each method of each class does in one of two sentences.
3