Question: (b) Write a Java subclass called Stock that inheritances from the superclass Item and implements Comparable interface with the following features: 1. Two private member

(b) Write a Java subclass called Stock that inheritances from the superclass Item and implements Comparable interface with the following features: 1. Two private member variables a. location, data type: String b. qty, data type: integer 2. One constructor with four parameters a. initialize the parent variable goods b. initialize the parent variable unitperbox c. initialize the variable location d. initialize the variable qty 3. Four methods with the following signatures a. public int compareTo (Stock a) compare To is a method that compares the total quantity of two objects. If their total quantity (unitperbox * qty) are the same, return O. If the total quantity of the object is larger than the total quantity of the object passed through parameter, return 1, otherwise return -1. b. public String ShowLocation() Return the location of the object. c. public int ShowQty () Return the qty of the object. d. public int Total() Return the total quantity of the object (i.e. unitperbox * qty)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
