Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
• Chapter 7: Arrays & the ArrayList Class• Chapter 8: A Second Look at Classes and Objects• Chapter 9: Text Processing and More about Wrapper Classes• Chapter 10: Inheritance
• Build experience using static fields.• Build experience implementing aggregation relations.• Build experience implementing inheritance relations.• Build experience using abstract classes.• Build experience using polymorphism.
ASSIGNMENT DESCRIPTION
• Type R products have a strong demand all year round. The price does not depend on season or quantity.• Type B products have a regular price and a bulky price. If a customer buys 100 or more units but less than 500, then the 5% discount will apply; for 500 or more units but less than 1500 the 15% discount will apply; for 1500 or more units the 25% discount will apply.• Type S products are seasonable. During the period starting November 1 st and until February 1st the price is discounted by 40%.
Thus, products must have an attribute for type besides name, and regular price. The main menu of your program should have three options: show the inventory, make an order, review the orders, and exit.
To make an order the user should select a product by name, enter quality, and specify the date of purchase. The program must calculate the total price and add an item to the order. A new order should be added to the order list.Page 2 of 7
There is no limit on how long the order list can be. When the user decides to exit the program, the program must save the order list to a file orders.txt.
REQUIREMENTS
(a) a question mark before invSize means that you decide on the access specifier for this class member;
(b) you decide on the names of the class members, the above diagram is an illustration only;
(c) you can add as many fields and methods as you want. For example, class Order may have information about the customer of type String (or maybe a new class);
(d) the class Date is not required, you may represent a date with three integer variables. Please control the correctness of the date input using your Project 1 materials.
The superclass Product must be an abstract class and have a static variable to hold the size of the inventory. The inventory from the text file must be saved in an array or ArrayList, assume that the inventory should not exceed 100 products. The text file with data must have at least two records for each of the three product types.
For the list of orders use the ArrayList class.
Use methods in your driver program whenever it is appropriate. Consider your Lab 2 experience and reuse methods.
You will create several versions, which is typical in software development—each version shown as a task below. After you have the first task completed, save your work as the first version of the project. Use the copy of the first version as the basis for the second version that satisfies the requirements of the second task. The copy of the second version is the basis for the third version that satisfies the requirements of the third task, and so on.Page 3 of 7
At the end, you need to submit the last successful version only. Moreover, you may create no versions and work on the final product from the beginning. However, be aware of the advantages of the version-based approach:
(d) it is helpful if you need to prove that it is your original work.
INSTRUCTIONS
Complete any of the above tasks missed, debug, test and polish the project as your Lab 3.3 assignment.
TASK #1
Create an abstract superclass Product with a static variable that holds the number of products in the inventory. Its value must grow as reading from the file progresses. You will use this variable whenever you need the size of the inventory. Override a default toString() method such that it returns product attributes, at least name, regular price, and type.
Create three subclasses for the superclass Product. Each subclass must have a constructor. Decide on the method
• For the S-product, the total is the regular price multiplied by the number of units outside the season or the 40% discounted price multiplied by the number of units during November, December, and January.
Create a main menu and make sure that you can upload and print the inventory. Use the superclass method toString() to print each object.
The advantage of inheritance is the ability to create a list (array) of superclass objects to be filled with objects of different subclasses. You can use the product’s position in the list to build the product’s ID. Page 4 of 7
TASK #2
Make sure that you can find a product in the inventory by the name inputted by the user. It can be the beginning of the implementation of the second option of the main menu. Use methods developed in the Lab 2. Note that Lab 2 results must be refined to be used in Lab 3.
TASK #3
Decide on how you will implement dates in your project. It can be a class or three integer values. I recommend creating a class Date that has a constructor that converts a string in the format “mm/dd/yyyy” into an object with three fields – month, day, and year. Do not forget to check the string and date for correctness.
Create a class Order that aggregates other classes – Product (the superclass due to polymorphism) and Date (if you use the class Date). Override a default toString() method to print an object of this class.
Add the quantity and date input to the second menu option. Remember, if the program reads a string from the keyboard after a number, you may need to handle the new line symbol left in the input buffer. When all the information is collected, the order is ready to be created. Make sure that you can create and print a new object of type Order.
TASK #4
Create an ArrayList of orders, and make sure that the user can add multiple orders to the list by implementing the review option of the main menu. This option should print the list of orders.
Implement the exit option of the menu. ArrayList of orders must be saved in the file orders.txt before the program quits.
GRADING GUIDELINES
The breakdown of points for this assignment is in the table below. Note, in addition to the correctness, some points count towards how well your code is written and documented. Well-written code uses proper indentation that follows the scope of your statements and employs intuitive and self-documenting variable names.
Your code should include comments that detail the purpose of blocks of code or individual statements. Good documentation does not imply that more is better. The goal is to be efficient, elegant, and succinct!
Grading item |
Points |
1. The software meets the specification:
• Classes are designed as required.
• Classes are in separate files.
• Array and/or ArrayList are used.
• File input and output are implemented.
|
20 |
2. The software is well documented:
• Required comments are included.
• Necessary comments are included.
• Javadoc format and tags used.
• A screenshot with the results is provided.
|
10 |
3. The implementation is error-free and well-tested:
• There are no compilation errors.
• The software produces no error for all valid inputs.
|
20 |
4. The project is complete and works correctly:
• All menu options are implemented.
• A list of products implements polymorphism.
• Total calculates correctly for all product types.
• Dates are checked for correctness.
• The exit is processed correctly.
|
40 |
5. The programming style is efficient:
• The indentations are correct.
• Naming is descriptive.
• Methods are appropriate.
|
10 |
SUBMISSION
You must submit only one, the most successful, version. Please review your work carefully before submitting it. Also, check the grading rubric to ensure that your program meets all requirements.
Your lab instructor will provide you with a detailed description of the submission process. The usual requirements are as follows.
a. A driver source code file named Lab3Driver_yourID.java. At the beginning of the source code file, you must have− information about the author: course, semester, lab section, first and last name, and ID− a brief description of the project− test data that you used to check the correctness of the program – for this project, it is the name of a text file with sample data.b. Source code files that implement classes that you created for the project: three classes for products, one class for order, and any additional classes that you created. You can name files in your way.c. A text file (.txt) with sample data.d. A text file (.txt) with resulting orders.e. Besides the source code, you must submit a screenshot with the program dialog and results (see Programming Assignments Requirements and Recommendations about the screenshot requirements).
5. If you have trouble with the submission, please contact your instructor for assistance.
POLICY ON CHEATING