Question: QUESTION 1 (a) Implement a class called StockItem, whose constructor and public methods are listed in the table below. Each stock item has attributes: ID,

 QUESTION 1 (a) Implement a class called StockItem, whose constructor and

QUESTION 1 (a) Implement a class called StockItem, whose constructor and public methods are listed in the table below. Each stock item has attributes: ID, name, stock level and price. These attributes have types String, String, int, double, respectively. Method Semantics StockItem(String i, String n, int Constructor method for class sl, double p) id() Returns the id of the stock item name() Returns the name of the stock item stockLevel() Returns the stock level of the stock item Price() Returns the price of the stock item toString() Returns a string representation of an instance of a stock item (6 marks) (b) Write a code fragment that creates two instances of your StockItem class and then uses an if-statement to determine the one with the lowest level of the two stock items. (4 marks) Total (10 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!