Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All of the classes are written and are at the bottom of the instructions. All I need is part 7 and 8 complete which is

All of the classes are written and are at the bottom of the instructions. All I need is part 7 and 8 complete which is writing test classes. Test1 and Test2 which is a JUnit test class. I also need JavaDoc comments. Look at parts 7 and 8 for more details. Thank you!

  • 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).
  1. Implement the classes using the design specified by this UML diagram. Here's the diagram: image text in transcribed
  2. 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.
  3. 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.
  4. 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
  5. 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.
  6. 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.
  7. 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.
  8. Start writing JavaDoc comments for your classes. They are required in Project 4b.
public interface PurchaseReceipt extends Comparable { public int getId(); public String getBuyer(); public String getSeller(); public double getAmount(); } 

________________________________________________________________________________

//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. public class Transaction implements PurchaseReceipt { private int _id; private String _buyer; private String _seller; private double _amount; private String _memo; private String _timestamp; public Transaction(int _id, String _buyer, String _seller, double _amount, String _memo, String _timestamp) { this._id = _id; this._buyer = _buyer; this._seller = _seller; this._amount = _amount; this._memo = _memo; this._timestamp = _timestamp; } public Transaction() { _id = 0; _buyer = ""; _seller = ""; _amount = 0.0; _memo = ""; _timestamp = ""; } public int getId() { return _id; } public String getBuyer() { return _buyer; } public String getSeller() { return _seller; } public double getAmount() { return _amount; } public String get_memo() { return _memo; } public String get_timestamp() { return _timestamp; } @Override public String toString() { return "ID: " + this.getId() + ", " + "Buyer: " + this.getBuyer() + ", " + "Seller: " + this.getSeller() + ", " + "Amount: $" + this.getAmount() + ", " + "Memo: " + this.get_memo() + ", " + "Timestamp: " + this.get_timestamp(); } //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. @Override public int compareTo(PurchaseReceipt purchaseReceipt) { return (int) (this.getAmount() - purchaseReceipt.getAmount()); } } 

________________________________________________________________________________

public class GoldTransaction extends Transaction { public int _carats; public double _weight; public GoldTransaction() { super(); } public GoldTransaction(int _id, String _buyer, String _seller, double _amount, String _memo, String _timestamp, int _carats, double _weight) { super(_id, _buyer, _seller, _amount, _memo, _timestamp); this._carats = _carats; this._weight = _weight; } public int get_carats() { return _carats; } public double get_weight() { return _weight; } @Override public String toString() { return "ID: " + this.getId() + ", " + "Buyer: " + this.getBuyer() + ", " + "Seller: " + this.getSeller() + ", " + "Amount: $" + this.getAmount() + ", " + "Memo: " + this.get_memo() + ", " + "Carats: " + this.get_carats() + ", " + "Weight: " + this.get_weight() + ", " + "Timestamp: " + this.get_timestamp(); } } 

________________________________________________________________________________

public class LumberTransaction extends Transaction { private int _grade; private double _weight; public LumberTransaction() { super(); } public LumberTransaction(int _id, String _buyer, String _seller, double _amount, String _memo, String _timestamp, int _grade, double _weight) { super(_id, _buyer, _seller, _amount, _memo, _timestamp); this._grade = _grade; this._weight = _weight; } public int get_grade() { return _grade; } public double get_weight() { return _weight; } @Override public String toString() { return "ID: " + this.getId() + ", " + "Buyer: " + this.getBuyer() + ", " + "Seller: " + this.getSeller() + ", " + "Amount: $" + this.getAmount() + ", " + "Memo: " + this.get_memo() + ", " + "Grade: " + this.get_grade() + ", " + "Weight: " + this.get_weight() + ", " + "Timestamp: " + this.get_timestamp(); } }
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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions