Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started