Question: Create a project in Java that consists of these files: TransactionChecker.java TransactionLogger.java TestTransactionChecker.java Transaction.java (from Project 4). Transactions.java is this: public class Transaction implements PurchaseReceipt

  1. Create a project in Java that consists of these files:
    • TransactionChecker.java TransactionLogger.java TestTransactionChecker.java Transaction.java (from Project 4). Transactions.java is this:
    • 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 @Override public int compareTo(PurchaseReceipt purchaseReceipt) { return (int) (this.getAmount() - purchaseReceipt.getAmount()); } } 
    Also download the transactions.txt file. Place it in the project folder. I can't provide the whole document since it's too big but here's a screenshot of sample data in it:
  2.  Create a project in Java that consists of these files: TransactionChecker.java
  3. Modify the TransactionChecker class:
    1. Make this class a derived class that extends the base class Observable.
    2. In the while loop, replace the printf statement with code that creates a Transaction object. For the transaction id, use an autogenerated id that starts with 1001 and increases by 1 for each new Transaction object created.
    3. After the Transaction object is created in the while loop, write an if statement that notifies the observers if a transaction is found where amount is greater than $50,000 and the buyer is Eugene Eko. Notify all observers by sending them the Transaction object. To do this, use the Observable methods setChanged and notifyObservers.
  4. Modify the TransactionLogger class:
    1. Have it implement the Observer interface, which means that an update method is required.
    2. Add an update method with this header:
      public void update(Observable obs, Object info) 
      Write the info object (which is actually a Transaction object) out to the log file. After that, flush the output buffer, which forces the info be written to disk. Don't forget the @Override statement, which indicates that you are either overriding a method from a base class or implementing a required method from an interface.
  5. Write a TestTransactionChecker class. In a main method:
    1. Declare and instantiate a new TransactionChecker object.
    2. Declare and instantiate a new TransactionLogger object.
    3. Add the TransactionLogger object as an observer to the TransactionChecker object.
    4. Call the checkTransactions method of the TransactionChecker object.

 

Transaction Helvetica Regular 12 aBIU 1.0 3 4 6 7 oshua Smith,Hilton Hotels,3973.19,2017 Oct 27 00:36:33 Onur Ayduk,Hilton Hotels,18013.51,2017 Oct 27 00:43:38 Frank Tadin, Star Airlines,9355.30,2017 Oct 27 02:39:26 Ali Samir, Star Airlines,14715.92,2017 Oct 27 04:19:44 Frank Tadin,American Airlines, 3469.86,2017 Oct 27 05:34:45 Tanya Brook, Worldwide Bank,3678.78,2017 Oct 27 05:35:37 Tanya Brook, Mainstay Bank,14060.79,2017 Oct 27 06:52:44 Calvin Chen, Hilton Hotels,6155.52,2017 Oct 27 08:07:30 Eugene Eko, American Airlines,2954.59,2017 Oct 27 08:19:46 Ali Samir,Worldwide Bank, 472.97,2017 Oct 27 08:21:16 Ryan Golden, Euro Bank, 798.22,2017 Oct 27 09:22:11 Ryan Golden, Euro Bank, 2439.25,2017 Oct 27 09:49:43 Onur Ayduk, Cosmic Travel,8662.39,2017 Oct 27 10:26:52 Calvin Chen, Chase Bank,5686.76,2017 Oct 27 11:42:36 Ryan Golden, Cosmic Travel,5974.14,2017 Oct 27 11:47:26 Calvin Chen, Mainstay Bank,184.49,2017 Oct 27 12:07:05 Ali Samir, Chase Bank,8501.71,2017 Oct 27 13:16:55 Onur Ayduk, Hilton Hotels,11817.45,2017 Oct 27 13:48:53 Ryan Golden, Euro Bank, 13356.02,2017 Oct 27 14:47:2.2 Onur Ayduk, Euro Bank, 33061.39,2017 Oct 27 15:48:57 Frank Tadin,Cosmic Travel,10206.86,2017 Oct 27 16:20:52 Eugene Eko, Euro Bank, 8460.60,2017 Oct 27 17:46:57 Onur Ayduk, Acme Airlines, 6269.59,2017 Oct 27 18:13:54 Frank Tadin,Acme Airlines,12746.79,2017 Oct 27 20:44:03 Ali Samir, Star Airlines,10747.78,2017 Oct 27 22:09:07 Joshua Smith,ABC Travel Agency,2747.59,2017 Oct 27 23:21:03 Onur Ayduk,Star Airlines, 4464.45,2017 Oct 27 23:39:50 Tanva Brook.Hilton Hotels,4424..12.2017 Oct 28 01:46:36 3 Transaction Helvetica Regular 12 aBIU 1.0 3 4 6 7 oshua Smith,Hilton Hotels,3973.19,2017 Oct 27 00:36:33 Onur Ayduk,Hilton Hotels,18013.51,2017 Oct 27 00:43:38 Frank Tadin, Star Airlines,9355.30,2017 Oct 27 02:39:26 Ali Samir, Star Airlines,14715.92,2017 Oct 27 04:19:44 Frank Tadin,American Airlines, 3469.86,2017 Oct 27 05:34:45 Tanya Brook, Worldwide Bank,3678.78,2017 Oct 27 05:35:37 Tanya Brook, Mainstay Bank,14060.79,2017 Oct 27 06:52:44 Calvin Chen, Hilton Hotels,6155.52,2017 Oct 27 08:07:30 Eugene Eko, American Airlines,2954.59,2017 Oct 27 08:19:46 Ali Samir,Worldwide Bank, 472.97,2017 Oct 27 08:21:16 Ryan Golden, Euro Bank, 798.22,2017 Oct 27 09:22:11 Ryan Golden, Euro Bank, 2439.25,2017 Oct 27 09:49:43 Onur Ayduk, Cosmic Travel,8662.39,2017 Oct 27 10:26:52 Calvin Chen, Chase Bank,5686.76,2017 Oct 27 11:42:36 Ryan Golden, Cosmic Travel,5974.14,2017 Oct 27 11:47:26 Calvin Chen, Mainstay Bank,184.49,2017 Oct 27 12:07:05 Ali Samir, Chase Bank,8501.71,2017 Oct 27 13:16:55 Onur Ayduk, Hilton Hotels,11817.45,2017 Oct 27 13:48:53 Ryan Golden, Euro Bank, 13356.02,2017 Oct 27 14:47:2.2 Onur Ayduk, Euro Bank, 33061.39,2017 Oct 27 15:48:57 Frank Tadin,Cosmic Travel,10206.86,2017 Oct 27 16:20:52 Eugene Eko, Euro Bank, 8460.60,2017 Oct 27 17:46:57 Onur Ayduk, Acme Airlines, 6269.59,2017 Oct 27 18:13:54 Frank Tadin,Acme Airlines,12746.79,2017 Oct 27 20:44:03 Ali Samir, Star Airlines,10747.78,2017 Oct 27 22:09:07 Joshua Smith,ABC Travel Agency,2747.59,2017 Oct 27 23:21:03 Onur Ayduk,Star Airlines, 4464.45,2017 Oct 27 23:39:50 Tanva Brook.Hilton Hotels,4424..12.2017 Oct 28 01:46:36 3

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!