Question
Create UML diagram for following specifications given by the client, who is a Reatil Store owner to you;- A RetailItem class is required to hold
Create UML diagram for following specifications given by the client, who is a Reatil Store owner to you;-
A RetailItem class is required to hold information about an item in a retail store. The class should have following fields;-
a) description;- the description field references a String object that holds a brief description about an item.
b) unitsOnHand;- The unitsOnHand field is an int variable that holds the number of units currently in inventory.
c) price;- The price filed is a double variable that holds the item's retail price.
In addition to the fields, the RetailItem class should have following constructors and methods.
d) Default Constructor;- A constructor which assigns 0 to unitsOnHand field, 0.0 to price and "nodesc" to description field.
e) Parameterized Constrtuctor;- The constructor that accepts the arguments for each field and stores them into their respective fields.
f) Accessors;- accessor method for each field, which returns the respective field value.
g) Sold method;- sold() method, which subtracts 1 from unitsOnHands value, everytime its called. Choose the appropriate return type for this method.
h) ReStock method;- reStock() method, which adds 1 to unitsOnHands everytime this method is called. Choose the appropriate return type for this method.
Part-2 Create class RetailItem and implement all points from A to H specified above. Demonstrate the class in a test program that creates a RetailItem object, and then call the sold function 2 times, which should display updated unitsOnHands after each call. Then call the reStock method 2 times, which should again display updated unitsOnHands after each call.
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