Question
In java create a Product class. A Product object represents a product stored in inventory. The Product class should have the following private instance variables:
In java create a Product class. A Product object represents a product stored in inventory.
The Product class should have the following private instance variables: productName, numberOnHand, numberOnOrder, and price.
Give the instance variables public 'get' and 'set' methods. The numberOnHand, numberOnOrder, and price 'set' methods will not accept a negative number.
Give the class a four argument constructor that populates the data in a Product object. Also, recreate the no-argument constructor. Remember that the numberOnHand, numberOnOrder, and price should not be allowed to have a value less than zero.
Also give the class an overridden toString method that reports on the data in a Product object.
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