All pastes #391851 Raw Edit

Stuff

public text v1 · immutable
·published 2007-03-12 13:42 UTC
rendered paste body
public class Account implements Cloneable {
  private static String accountNumber;
  public static double balance = 0;
  static Customer customer = new Senior();
  public static Transaction[] trans = new Transaction[100];
  public Account() {
  }
  
  /* getBalance
  *  pre- existing account to retrieve balance from
  *  post-  account is not modifed
  *  @param return - The specified balance is returned
  */
  public static double getBalance()
  {
    return balance;
  }

  /* getCustomer
    *  pre- existing customer to get
    *  post-  the customer is not modifed
    *  @param return - The specified customer is returned
  */
  public static Customer getCustomer()
  {
    return customer;
  }
  
  
  /* setCustomerd
  *  pre- 
  *  post-  the customer is added
  */
  public static void setCustomer(String name, String address, String telephoneNumber, String accountNumber1, int age)
  {
    customer.setName(name);
    customer.setAddress(address);
    customer.setTelephoneNumber(telephoneNumber);
    customer.setAccountNumber(accountNumber1);
    customer.setAge(age);
  }
  
  
  /* toString
  *  pre- existing customer to display
  *  post-  customer information is displayed
  *  @param return - displays customer information
  */
  public String toString()
  {
    return "\nCustomer name: " + customer.getName() + "\nAccount number: " + customer.getAccountNumber() + "\nBalance: " + balance + "\nTelephone Number: " + customer.getTelephoneNumber() + "\nAge: " + customer.getAge() + "\nAddress: " + customer.getAddress();
  }

}






public class Bank {
  public static Account[] accounts = new Account[100];
  public static int counter = 0;
  public static int tCounter = 0;
  public Bank() {
  }
  
  
  /* addAccount
  *  pre- 
  *  post-  an account is added to the array of accounts
  */
  public static void addAccount(String name, String address, String telephoneNumber, String accountNumber, int age) 
  {
    accounts[counter].setCustomer(name, address, telephoneNumber, accountNumber, age);
    counter++;
  }
  
  /* getAccount
  *  pre- existing account to get
  *  post-  account is not modifed
  *  @param accountValue - which account to return
  *  @param return - The specified account is returned
  */
  public static Account getAccount(int accountValue)
  {
    return accounts[accountValue];
  }
  
  /* makeWithdrawal
  *  pre- existing account, money in the bank
  *  post-  the amount of money is withdrawn from the specified account
  *  @param amount - Amount to withdraw
  *  @param accountNumber - number of the account to withdraw from
  *  @param date - date transaction was made
  */
  public static void makeWithdrawal(double amount, String accountNumber, String date )
  {
    Transaction.processTransaction(amount, accountNumber, date, "Withdrawal");
  }
  
  
  /* makeDeposit
  *  pre- existing account
  *  post-  the amount of money is deposited in the bank
  *  @param amount - Amount to withdraw
  *  @param accountNumber - number of the account to withdraw from
  *  @param date - date transaction was made
  */
  public static void makeDeposit(double amount, String accountNumber, String date )
  {
    Account.trans[tCounter].processTransaction(amount, accountNumber, date, "Deposit");
  }


}






public abstract class Customer {
  private static String name, telephoneNumber, address, accountNumber;
  private static int age;
  public Customer() {
  //if this does not work, put accessors in constructor here
  }
  
  /* setName
  *  pre- 
  *  post-  name of customer set
  *  @param newName - name of customer
  */
  public static void setName(String newName)
  {
    name = newName;
  }
  
  
  /* setTelephoneNumber
  *  pre- 
  *  post-  phone number of customer set
  *  @param newPhone - phone number
  */
  public static void setTelephoneNumber(String newPhone)
  {
    telephoneNumber = newPhone;
  }
  
  /* setAddress
  *  pre- 
  *  post-  Address of customer set
  *  @param newAddress - address of customer
  */
  public static void setAddress(String newAddress)
  {
    address = newAddress;
  }
  
  /* setAccountNumber
  *  pre- 
  *  post-  account number of customer set
  *  @param newAccountNumber - account number of customer
  */
  public static void setAccountNumber(String newAccountNumber)
  {
    accountNumber = newAccountNumber;
  }
  
  /* setAge
  *  pre- 
  *  post-  age of customer set
  *  @param newName - age of customer
  */
  public static void setAge(int newAge)
  {
    age = newAge;
  }
  
  
  /* getName
  *  pre- 
  *  post-  name of customer retrievedd
  *  @return - name returned
  */
  public static String getName()
  {
    return name;
  }
  
  /* getTelephoneNumber
  *  pre- 
  *  post-  number of customer retrievedd
  *  @return - number returned
  */
  public static String getTelephoneNumber()
  {
    return telephoneNumber;
  }
  
  /* getAddress
  *  pre- 
  *  post-  address of customer retrievedd
  *  @return - address returned
  */
  public static String getAddress()
  {
    return address;
  }
  
  
  /* getAccountNumber
  *  pre- 
  *  post-  Account number of customer retrievedd
  *  @return - Account number returned
  */
  public static String getAccountNumber()
  {
    return accountNumber;
  }
  
  
  /* getAge
  *  pre- 
  *  post-  Age of customer retrievedd
  *  @return - Age returned
  */
  public static int getAge()
  {
    return age;
  }
  
  public abstract double getSavingsInterest();
  public abstract double getCheckInterest();
  public abstract double getCheckCharge();
  public abstract double getOverdraftPenalty();

}



public class SavingsAccount extends Account {
  public SavingsAccount() {
  }
  
  
  /* deposit
  *  pre- existing Account
  *  post-  money deposited
  *  @param amount - amount to be deposited
  *  @param accountNumber - number of account to be modified
  *  @param date - date transaction occurs
  */
  public static void deposit(double amount, String accountNumber, String date)
  {
    Bank.makeDeposit(amount, accountNumber, date);
  }


  /* withdraw
  *  pre- existing Account
  *  post-  specified money withdrawn
  *  @param amount - amount to be withdrawn
  *  @param accountNumber - number of account to be modified
  *  @param date - date transaction occurs
  */
  public static void withdraw(double amount, String accountNumber, String date)
  {
    Bank.makeWithdrawal(amount, accountNumber, date);
  }

  /* addInterest
  *  pre- existing Account
  *  post-  interest added
  *  @param accountNumber - number of account to be modified
  */
  public void addInterest(String accountNumber)
  {
    if (Customer.getAge() < 24)
    {
      Bank.accounts[Bank.counter].balance = Bank.accounts[Bank.counter].balance * Student.getSavingsInterest();
    }
  }

}





public class Senior extends Customer {
  private final double SAVINGS_INTEREST = 3.5;
  private final double CHECK_INTEREST = 2.1;
  private final double CHECK_CHARGE = .25;
  private final double OVERDRAFT_PENALTY = 15;
  public Senior() {
  }
  
  /* getSavingsInterest
  *  pre- 
  *  post- constant number returned
  *  @param return - Constant number set for Interest
  */
  public double getSavingsInterest() {
    return SAVINGS_INTEREST;
  }
  
  /* getCheckInterest
  *  pre- 
  *  post-  constant number returned
  *  @param return - Constant number set for check_interested returnedd
  */
  public double getCheckInterest() {
    return CHECK_INTEREST;
  }
  
  /* getCheckcharge
 *  pre- 
 *  post-  constant number returned
 *  @param return - Constant number set for check_charge returnedd
 */
  public double getCheckCharge() {
    return CHECK_CHARGE;
  }
  
  /* getOverdraftPenalty
 *  pre- 
 *  post-  constant number returned
 *  @param return - Constant number set for OverdraftPenalty returnedd
 */
  public double getOverdraftPenalty() {
    return OVERDRAFT_PENALTY;
  }
}




public class Student extends Customer {
  public static final double SAVINGS_INTEREST = 3.3;
  public final double CHECK_INTEREST = 1.6;
  public final double CHECK_CHARGE = .75;
  public final double OVERDRAFT_PENALTY = 25;

  public Student() {
  }
  
  /* getSavingsInterest
  *  pre- 
  *  post- constant number returned
  *  @param return - Constant number set for Interest
  */
  public double getSavingsInterest()
  {
    return SAVINGS_INTEREST;
  }
  
  /* getCheckInterest
  *  pre- 
  *  post-  constant number returned
  *  @param return - Constant number set for check_interested returnedd
  */
  public double getCheckInterest()
  {
    return CHECK_INTEREST;
  }
  
  /* getCheckcharge
 *  pre- 
 *  post-  constant number returned
 *  @param return - Constant number set for check_charge returnedd
 */
  public double getCheckCharge()
  {
    return CHECK_CHARGE;
  }
  
  /* getOverdraftPenalty
 *  pre- 
 *  post-  constant number returned
 *  @param return - Constant number set for OverdraftPenalty returnedd
 */
  public double getOverdraftPenalty()
  {
    return OVERDRAFT_PENALTY;
  }
}




public class Transaction {
  public static String accountNumber, transactionType, date;
  public static double amount;
  public Transaction() {
  }
  
  
  /* processTransaction
  *  pre- existing Account
  *  post-  transaction completed
  *  @param amount1 - amount to be deposited
  *  @param accountNumber1 - number of account to be modified
  *  @param date1 - date transaction occurs
  *  @param type - deposit or withdraw
  */
  public static void processTransaction( double amount1, String accountNumber1, String date1, String type)
  {
    amount = amount1;
    date = date1;
    accountNumber = accountNumber1;
    if (type == "Deposit")
    {
      Bank.accounts[Bank.counter].balance += amount1;
    }
    else
    {
      Bank.accounts[Bank.counter].balance -= amount1;
    }
    transactionType = type;
  }

}




public class CheckingAccount extends Account {
  public CheckingAccount() {
  }
  
  
  /* deposit
  *  pre- existing account to deposit money into
  *  post-  money is deposited
  *  @param amount - amount to deposit
  *  @param accountNumber - which account to return
  *  @param date - The specified account is returned
  */
  public static void deposit(double amount,String accountNumber, String date)
  {
    Bank.makeDeposit(amount, accountNumber, date);
  }
  
  
  /* withdraw
  *  pre- existing account
  *  post-  the amount of money is withdrawn in the bank
  *  @param amount - Amount to withdraw
  *  @param accountNumber - number of the account to withdraw from
  *  @param date - date transaction was made
  */
  public static void withdraw(double amount,String accountNumber, String date)
  {
    Bank.makeWithdrawal(amount, accountNumber, date);
  }
  
  
  /* addInterest
  *  pre- existing account
  *  post- interested is added
  */
  public static void addInterest()
  {
    
  }
  
}




public class Adult extends Customer {
  private final double SAVINGS_INTEREST = 3.2;
  private final double CHECK_INTEREST = 1.8;
  private final double CHECK_CHARGE = .50;
  private final double OVERDRAFT_PENALTY = 20;

  public Adult() {
  }
  
  /* getSavingsInterest
  *  pre- 
  *  post- constant number returned
  *  @param return - Constant number set for Interest
  */
  public double getSavingsInterest() {
    return SAVINGS_INTEREST;
  }
  
  /* getCheckInterest
  *  pre- 
  *  post-  constant number returned
  *  @param return - Constant number set for check_interested returnedd
  */
  public double getCheckInterest() {
    return CHECK_INTEREST;
  }
  
  /* getCheckcharge
 *  pre- 
 *  post-  constant number returned
 *  @param return - Constant number set for check_charge returnedd
 */
  public double getCheckCharge() {
    return CHECK_CHARGE;
  }
  
  
  /* getOverdraftPenalty
 *  pre- 
 *  post-  constant number returned
 *  @param return - Constant number set for OverdraftPenalty returnedd
 */
  public double getOverdraftPenalty() {
    return OVERDRAFT_PENALTY;
  }


}