edu.uci.ics.inf111.dvdvendor.app
Class Transaction

java.lang.Object
  extended by edu.uci.ics.inf111.dvdvendor.app.Transaction
Direct Known Subclasses:
RentTransaction, ReturnTransaction

public abstract class Transaction
extends java.lang.Object

The Transaction abstract class is extended by any class which represents a transaction in our point of sale. This class has been created to simplify the creation of future transaction. In our example, RentTransaction and ReturnTransaction extend this class. The class provides common accessor methods for the fields.


Field Summary
private  java.lang.String cardNumber
          The card number for the transaction.
private  double cost
          The cost for the transaction.
private  java.lang.String dateTime
          The date and time for the transaction.
 
Constructor Summary
Transaction()
           
 
Method Summary
static Transaction createTransaction(java.lang.String line)
          Static method that creates a Rent or a Return Transaction based on the input String that represents a line in the transactionDB file
 java.lang.String getCardNumber()
          An accessor method which returns the card number for the transaction.
 double getCost()
          An accessor method which returns the cost for the transaction.
 java.lang.String getDateTime()
          An accessor method which returns the date and time for the transaction.
 void setCardNumber(java.lang.String cardNumber)
          An accessor method which sets the card number for the transaction.
 void setCost(double cost)
          An accessor method which sets the cost for the transaction.
 void setDateTime(java.lang.String dateTime)
          An accessor method which sets the date and time for the transaction.
abstract  java.lang.String toString()
          Abstract method to define the toString method in each class that extends this abstract class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dateTime

private java.lang.String dateTime
The date and time for the transaction.


cost

private double cost
The cost for the transaction.


cardNumber

private java.lang.String cardNumber
The card number for the transaction.

Constructor Detail

Transaction

public Transaction()
Method Detail

setDateTime

public void setDateTime(java.lang.String dateTime)
An accessor method which sets the date and time for the transaction.


getDateTime

public java.lang.String getDateTime()
An accessor method which returns the date and time for the transaction.


setCost

public void setCost(double cost)
An accessor method which sets the cost for the transaction.


getCost

public double getCost()
An accessor method which returns the cost for the transaction.


setCardNumber

public void setCardNumber(java.lang.String cardNumber)
An accessor method which sets the card number for the transaction.


getCardNumber

public java.lang.String getCardNumber()
An accessor method which returns the card number for the transaction.


createTransaction

public static Transaction createTransaction(java.lang.String line)
                                     throws InvalidBarCodeException
Static method that creates a Rent or a Return Transaction based on the input String that represents a line in the transactionDB file

Parameters:
line - String that represents a line in the TransactionDB file
Returns:
Transaction An object with the created Transaction
Throws:
InvalidBarCodeException - if the BarCode read is not valid

toString

public abstract java.lang.String toString()
Abstract method to define the toString method in each class that extends this abstract class. This method will take the values of the class and will concatenate them in a String with the expected format in the Transaction database.

Overrides:
toString in class java.lang.Object
Returns:
String Represents the transaction to be stored in the Transaction database.