Question: Constructor ( 3 Parameters ) : The constructor should accept the item's name, cost, and price as arguments and assign these values to the object's
Constructor Parameters:
The constructor should accept the item's name, cost, and price as arguments and assign
these values to the object's corresponding instance variables.
The constructor should also initialize weight to kg and taxable to true by default.
Note: Ensure that the constructor does not allow negative values for the price or cost If
negative values are passed, set them to and print an appropriate error message.
Add Accessor and Mutator Methods:
Provide getter and setter methods for all instance variables.
Ensure that the setter methods for price, cost, and weight do not allow negative values.
Add the increaseCost Method:
This method should increase the cost price of the item by each time it is called. This is a
void method as it modifies the current state of the object.
Add the profit Method:
This method should accept no parameters and return the profit of the item, which is calculated
as the selling price minus the cost price. Note: Ignore taxes in this calculation.
Add the toString Method:
This method should display the contents of the item's instance variables in a wellformatted
string. For example:
"Item: Desk Chair, Price: AED, Cost: AED, Weight: kg Taxable: true"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
