To Documents
IT 313 -- Project 7
Observer Software Pattern -- Transaction Observer. 75 points.
Goal: Use the classes Transaction,
TransactionChecker (Observable), 
TransactionLogger (Observer),as specified in Details 2 and 3.  Write a TransactionChecker class
as specified in Detail 4.
Deliverables: Zip file of: the IntelliJ project with two 
modules: (1) deliverables, which contains the classes 
Transaction.java, TransactionChecker.java,
TransactionLogger.java, and 
TestTransactionChecker.java (don't forget the source code comments), (2) 
observer, which contains the package it313.util; this 
package contains the
Observable.java and
Observer.java files from the Observer Example.
Important: use the Observable class and 
Observer interface from the Observer Example.
Do not use the Observable.java and Observer.java files from the Java Class Library because these
files are depreciated. 30 point deduction if you use the files from the Java 
Class Library.
Also, remember: don't compare strings for equality like this:
     
s == t
Compare for string 
equality like this:
      s.equals(t)
Details
- Create a project (named Proj5Smith if Smith is your last name) that 
consists of these files:
 
- TransactionChecker.java   
TransactionLogger.java
 TestTransactionChecker.java   Transaction.java
 Transaction.java: the Transaction class should contain these fields:
 fields id (int), buyer (String), 
seller (String), amount (String), 
timestamp (String).
 The Transaction class should also contain a parameterized constructor and a 
toString method.
 Also download the transactions.txt file.  Place it in the project folder.
- Download the Observable.java and Observer.java files from the Observer Example into the package 
it313.util. Do not use the observer files from the Java 
class library, which are depreciated. 30 point deduction if you use them.
- Modify the TransactionChecker class:
 
- Make this class a derived class that extends the base class Observable.
- 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.
- 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.
 
- Modify the TransactionLogger class:
 
- Have it implement the Observer interface, which means that an update method 
is required.
- 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.
 
- Write a TestTransactionChecker class. In a 
main method:
 
- Declare and instantiate a new TransactionChecker object.
- Declare and instantiate a new TransactionLogger object.
- Add the TransactionLogger object as an observer to the 
TransactionChecker object.
- Call the checkTransactions method of the
TransactionChecker object.
- Close the TransactionLogger object.
 
Grading Breakdown: TransactionChecker: 25%;
TransactionLogger: 25%; TestTransactionChecker: 25%; Comments: 15%; 
Indentation: 5%; Properly Submitted: 5%.