Class PaymentProcessor

java.lang.Object
  extended by PaymentProcessor

public class PaymentProcessor
extends java.lang.Object

Class to do data entry and simple processing of payments. Will maintain an ordered list of payments where each new payment is added to the end of the list and payments can be retrieved by list position.


Constructor Summary
PaymentProcessor(int capacity)
          Creates payment processor with no payments in the list.
 
Method Summary
 void addPayment(Payment payment)
          Add given payment to end of list of payments to be processed.
 int getCapacity()
          Get capacity of list.
 int getNumberOfPayments()
          Get count of number of payments in the list.
 Payment getPayment(int position)
          Get specified payment number.
 double getSumOfPayments()
          Get sum of all payments in the list.
static Payment inputNewPayment()
          User inputs valid payment information, then method returns object representing the payment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PaymentProcessor

public PaymentProcessor(int capacity)
Creates payment processor with no payments in the list.

Precondition: capacity >= 0.

Parameters:
capacity - Maximum number of payments that can be placed in the list.
Method Detail

inputNewPayment

public static Payment inputNewPayment()
User inputs valid payment information, then method returns object representing the payment. Payment information includes account ID and payment amount. The ID must be two letters followed by four digits. The payment amount must be greater than zero. If either of the input items is invalid, user is notified and prompted to re-input.

Returns:
Payment object representing valid user input.

addPayment

public void addPayment(Payment payment)
Add given payment to end of list of payments to be processed.

Precondition: payment != null.

Precondition: getNumberOfPayments() < getCapacity().

Parameters:
payment - A Payment object to be processed

getSumOfPayments

public double getSumOfPayments()
Get sum of all payments in the list.

Returns:
Double sum of all payments in the list.

getNumberOfPayments

public int getNumberOfPayments()
Get count of number of payments in the list.

Returns:
Integer count of number of payments in the list.

getCapacity

public int getCapacity()
Get capacity of list.

Returns:
Capacity of the list.

getPayment

public Payment getPayment(int position)
Get specified payment number.

Precondition: 0 <= position < getNumberOfPayments().

Parameters:
position - Integer position in the list. First position is 0.
Returns:
Payment object at the specified position.