Question: a. Define class Stock including constructor, accessor methods, mutator methods, toString() method, the implementation of getPayment Amount() and compare To() method. The getPayment Amount() method

 a. Define class Stock including constructor, accessor methods, mutator methods, toString()

a. Define class Stock including constructor, accessor methods, mutator methods, toString() method, the implementation of getPayment Amount() and compare To() method. The getPayment Amount() method used to calculate the total cost by multiplying quantity with pricePeritem while compareTo() method used to compare the price of two Stock objects.

b. Write a test program that creates two Stock objects and assign the appropriate values to each field.

i. Invoke compareTo() method to compare the pricePeritem of two Stock objects and print out the results.

ii. Invoke getPaymentAmount() method to obtain the total cost for each object

iii. Print out all the information for each object

#java urgent!!

java lang. Comparable - D + stock -part Number: String -part Description string |-quantity: int 1-propor Item: double + Stock (port Number: String part Description: String, quantity: inti pricolter Item double compare to Cobject : 0): Payable get Payment Amount (); double

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!