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).
PurchaseReceipt.java file:
// 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( ); }
- Details:
- Implement the classes using the design specified by this UML diagram. Here's the 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, which inherits from the Comparable interface. Test the compareTo method in the Transaction class to make sure that its objects are compared correctly.
- Implement the Comparable interface for the Transaction class so that the items in the Project 4b TransactionManager collection can be sorted before being returned by the various methods. This means that you must supply a compareTo method.
- 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.
- Implement the classes using the design specified by this UML diagram. Here's the diagram:
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
Get step-by-step solutions from verified subject matter experts
