You have three classes for each type of products. It is time to think about how to improve the data model – all three types have enough in common to be child classes of one parent class. Thus, the first thing to do is create a superclass and make three product type classes subclasses. Then,  move as many members (fields and methods) from Type X, Y, and Z product classes to a superclass as possible. Change the constructors appropriately. The advantage of inheritance is the ability to create an array of superclass objects to be filled with  objects of different subclasses. Thus, your inventory is in one array. Use the product’s index in the array  to build the product’s ID (I would recommend starting with 1). In the superclass, create a static variable  that holds the number of products available in the inventory. It must grow as reading from the file  progresses. Override a default toString() method for a superclass such that it shows product ID, name, regular  price, and type. At this moment, make sure that all modifications you have made keep your application alive and  working. The next step is to add three new classes to the project:  • Create a class to represent the user – hardware store customer. You must decide what members  this class needs. Ask the user to input necessary information. • You may notice that the date of the year is a complicated piece of data. Create a class Date that  converts a string of the form of “mm/dd/yyyy” into an object with three fields – month, day, and  year. The class constructor may do this job, but do not forget to check the string for correctness. Once you have this class ready, input the date as a string with the following converting into an  object of type Date. Remember, if you read a string from the keyboard after a number, you  may need to handle the new line symbol left in the input buffer. • The result of your application is an order that must have the customer’s information, the date,  the product information, and the total amount to pay. Thus, the third class to add is the class  Order. When all the information is collected, the order is ready to be created and printed out.  Outputting the order is the primary behavior of an object of type Order, and it is the final step  of your application. Thus, class Order aggregates the customer’s info, date, product info, and  total. Please note that Type X and Type Y products need only regular price and amount to  calculate the total, while Type Z products must also consider the date. The input and output examples for Types Y and Z are   User: Vladimir Kuperman The inventory: 1 Light Bulb 60W 3.0 Type X 2 Light Bulb 100W 5.99 Type X 3 Steel Bolt M5 0.15 Type Y 4 Steel Bolt M8 0.25 Type Y 5 Hose 25 feet 10.0 Type Z 6 Hose 50 feet 15.0 Type Z Your choice: 3 Number of units: 1000 What is the purchasing date? (mm/dd/yyyy) 12/12/2021 ********************************* Date 12/12/2021 ********************************* Vladimir Kuperman Your item:  +----+--------------+------+----+ |ID | Name |Price |Type| +----+--------------+------+----+ |3 Steel Bolt M5 0.15 Y | +----+--------------+------+----+ in the amount of 1000 *If you buy more than 1500 units you would pay $0.14 per unit. ********************************* Your total: 127 dollars 50 cents Save to file? (Y/N) Y   User: Vladimir Kuperman The inventory: 1 Light Bulb 60W 3.0 Type X 2 Light Bulb 100W 5.99 Type X 3 Steel Bolt M5 0.15 Type Y 4 Steel Bolt M8 0.25 Type Y 5 Hose 25 feet 10.0 Type Z 6 Hose 50 feet 15.0 Type Z Your choice: 5 Number of units: 10 What is the purchasing date? (mm/dd/yyyy) 10/12/2021 ********************************* Date 10/12/2021 ********************************* Vladimir Kuperman Your item:  +----+--------------+------+----+ |ID | Name |Price |Type| +----+--------------+------+----+ |5 Hose 25 feet 10.0 Z | +----+--------------+------+----+ in the amount of 10 ********************************* Your total: 70 dollars 0 cents Save to file? (Y/N)        The program must have one superclass and three subclasses for three types of products according to  the description given in Programming Project 1.  The program must read the inventory from the file into one array for all three types of products. Each  element of the array must be an object of one of the subclasses according to the information in the file.  Product ID must be formed automatically using a static variable. The user must be registered in the system, and the corresponding object must be created. Then, the user chooses a product from the list, specifies an amount and the date of planned purchasing. The date, user, product, amount, and the total must be aggregated in an object of type Order and  outputted. For this assignment, it is sufficient to output the order to the console. However, additional saving the  order in the file will be considered as a plus. The test plan must be developed for the program. Consider and test different inputs that may cause  errors: incorrect file records, wrong date format, invalid user’s choice.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

language java

 

 

You have three classes for each type of products. It is time to think about how to improve the data model – all three types have enough in common to be child classes of one parent class. Thus, the first thing to do is create a superclass and make three product type classes subclasses. Then, 
move as many members (fields and methods) from Type X, Y, and Z product classes to a superclass as possible. Change the constructors appropriately. The advantage of inheritance is the ability to create an array of superclass objects to be filled with 
objects of different subclasses. Thus, your inventory is in one array. Use the product’s index in the array 
to build the product’s ID (I would recommend starting with 1). In the superclass, create a static variable 
that holds the number of products available in the inventory. It must grow as reading from the file 
progresses.
Override a default toString() method for a superclass such that it shows product ID, name, regular 
price, and type.
At this moment, make sure that all modifications you have made keep your application alive and 
working.
The next step is to add three new classes to the project: 
• Create a class to represent the user – hardware store customer. You must decide what members 
this class needs. Ask the user to input necessary information.
• You may notice that the date of the year is a complicated piece of data. Create a class Date that 
converts a string of the form of “mm/dd/yyyy” into an object with three fields – month, day, and 
year. The class constructor may do this job, but do not forget to check the string for correctness.
Once you have this class ready, input the date as a string with the following converting into an 
object of type Date. Remember, if you read a string from the keyboard after a number, you 
may need to handle the new line symbol left in the input buffer.
• The result of your application is an order that must have the customer’s information, the date, 
the product information, and the total amount to pay. Thus, the third class to add is the class 
Order. When all the information is collected, the order is ready to be created and printed out. 
Outputting the order is the primary behavior of an object of type Order, and it is the final step 
of your application. Thus, class Order aggregates the customer’s info, date, product info, and 
total. Please note that Type X and Type Y products need only regular price and amount to 
calculate the total, while Type Z products must also consider the date.
The input and output examples for Types Y and Z are

 

User: Vladimir Kuperman
The inventory:
1 Light Bulb 60W 3.0 Type X
2 Light Bulb 100W 5.99 Type X
3 Steel Bolt M5 0.15 Type Y
4 Steel Bolt M8 0.25 Type Y
5 Hose 25 feet 10.0 Type Z
6 Hose 50 feet 15.0 Type Z
Your choice: 3
Number of units: 1000
What is the purchasing date? (mm/dd/yyyy)
12/12/2021
*********************************
Date 12/12/2021
*********************************
Vladimir Kuperman
Your item: 
+----+--------------+------+----+
|ID | Name |Price |Type|
+----+--------------+------+----+
|3 Steel Bolt M5 0.15 Y |
+----+--------------+------+----+
in the amount of 1000
*If you buy more than 1500 units you would pay $0.14 per unit.
*********************************
Your total: 127 dollars 50 cents
Save to file? (Y/N) Y

 

User: Vladimir Kuperman
The inventory:
1 Light Bulb 60W 3.0 Type X
2 Light Bulb 100W 5.99 Type X
3 Steel Bolt M5 0.15 Type Y
4 Steel Bolt M8 0.25 Type Y
5 Hose 25 feet 10.0 Type Z
6 Hose 50 feet 15.0 Type Z
Your choice: 5
Number of units: 10
What is the purchasing date? (mm/dd/yyyy)
10/12/2021
*********************************
Date 10/12/2021
*********************************
Vladimir Kuperman
Your item: 
+----+--------------+------+----+
|ID | Name |Price |Type|
+----+--------------+------+----+
|5 Hose 25 feet 10.0 Z |
+----+--------------+------+----+
in the amount of 10
*********************************
Your total: 70 dollars 0 cents
Save to file? (Y/N) 

 

 

 

The program must have one superclass and three subclasses for three types of products according to 
the description given in Programming Project 1. 
The program must read the inventory from the file into one array for all three types of products. Each 
element of the array must be an object of one of the subclasses according to the information in the file. 
Product ID must be formed automatically using a static variable.
The user must be registered in the system, and the corresponding object must be created. Then, the
user chooses a product from the list, specifies an amount and the date of planned purchasing.
The date, user, product, amount, and the total must be aggregated in an object of type Order and 
outputted.
For this assignment, it is sufficient to output the order to the console. However, additional saving the 
order in the file will be considered as a plus.
The test plan must be developed for the program. Consider and test different inputs that may cause 
errors: incorrect file records, wrong date format, invalid user’s choice.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY