Question: Goal: Implement and test the base class Transaction, and the derived classes GoldTransaction, and LumberTransaction. Deliverables: PurchaseReceipt.java, Transaction.java, GoldTransaction.java, LumberTransaction.java, Test1.java (traditional tests), Test2.java (JUnit

Goal: Implement and test the base class Transaction, and the derived classes GoldTransaction, and LumberTransaction.

Deliverables: PurchaseReceipt.java, Transaction.java, GoldTransaction.java, LumberTransaction.java, Test1.java (traditional tests), Test2.java (JUnit tests).

Details:

Implement the classes using the design specified by this UML diagram.

Use a package that contains the Transaction class and its derived classes. Use this package statement:

package it313.proj4.>;

The Test1 and Test2 classes should not be placed in this package.

You may use Eclipse to generate your constructors, getters, and toString methods for your classes. Recall how to set Eclipse to use the underscore ( _ ) prefix for instance variables and a prefix for the parameters, such as the if you want one.

Instance variable information:

Class Instance Variable Information
Transaction _id 4 digit value identifying the transaction
Transaction _seller Person or organization selling the commodity
Transaction _buyer Person or organization buying the commodity
Transaction _amount Amount paid for the commodity
Transaction _memo Details about the transaction
Transaction _timestamp Date and time of the transaction
GoldTransaction _carats Purity of the gold, value from 1 to 24
GoldTransaction _weight Weight of gold sold in grams
LumberTransaction _grade Grade of lumber, value from 1 (best) to 4
LumberTransaction _weight Weight of lumber sold in tons

The Transaction class implements the PurchaseReceipt interface,

// This interface is implemented by the Transaction class in Project 4.

package it313.proj4;

public interface PurchaseReceipt extends Comparable {

public int getId( );

public String getBuyer( );

public String getSeller( );

public double getAmount( ); }

which inherits from the Comparable interface. This means that in addition to supplying the methods getId, getBuyer, getSeller, and getAmount, a compareTo method must be supplied. It should return 1 if this._id > other._id, it should return -1 if this._id > other._id; it should return 0 if this._id == other._id. Test the compareTo method in the Transaction class to make sure that its objects are compared correctly.

Include a traditional test class Test1 and a JUnit test class Test2 that test all of the methods in the Transaction class, and all of the non-inherited methods in the derived classes. Overridden methods must be tested again for the derived classes.

Start writing JavaDoc comments for your classes. They are required in Project 4b.

Would really appreciate some help on how to do this and write all the classes, including the tests Test1 and Test2.

Also what should be written as seperate files and what to import not import and everything else.

Gold Iransaction +_carats int + weight: double + GoldTransaction) + GoldTransaction(id: int, seller String, buyer: String, amt: double, memo String, ts: String, carats: int, weight: double) + getCarats(): int +getWeight): double toString String Transaction id int seller String interface>> Comparable PurchaseReceipt> buyer: String +compareTo(other: Object): int amount: double memo String timestamp String Transaction(id: int, seller: String, buyer String, getld) int + Transaction) interface PurchaseReceipt +getld): int + getBuyer) String +getSeller) String +getAmount): double + compareToother: Object): int amt: double, memo String, ts: String) + getBuyer) String +getSeller) String +getMemo) String +toString) String +getAmount) double +getTimeStamp): String LumberTransaction _grade int _weight: double +LumberTransaction() + LumberTransaction(id: int, seller: String, buyer String, amt: double, memo String, ts: String, grade int, weight: double) + getGrade): int getWeigh) double toString String

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!