Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task - 2 : [ 5 0 pts . ] Write a java program to implement the following OrderingSystem class as shown in figure (
Task:
pts
Write a java program to implement the following OrderingSystem class as shown in figure a:
Figure a
Order
productName: String
quantity: int
set productName quantity: void
setProductName productName: void
setQuantity quantity: void
getProductName: String
getQuantity: int
readInput: void
toString: String
Figure b
This class has one private variable totalQuantityordered of type double and the array of objects of Order class. This class also have three methods. computeTotalQuantity this method computes the total quantity ordered for this order. getData this method first asks the user about how many products user want to order. Then, it creates the array of Order accordingly and calls the readInput method of Order class to get data from user. writeData this method prints out the total quantity ordered and calls the tostring method of Order class to print the details of each product ordered.
The orderingsystem class uses the order class to store the information of product and quantity. Create the Order class separately as shown in figure b:
The Order class has two private variables, productName and quantity. This class has reasonably defined constructors noarguments and arguments the noargument constructor must call the constructor that accepts arguments with reasonable arguments and the arguments constructor calls the set method that sets the values for productName and quantity. This
COPAssignment
Page of
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