Answered step by step
Verified Expert Solution
Link Copied!

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:
    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.
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

Students also viewed these Databases questions

Question

How many people will receive the message?

Answered: 1 week ago

Question

Discuss the four types of probability sampling. (8)

Answered: 1 week ago

Question

f. Did they change their names? For what reasons?

Answered: 1 week ago