// ********************************************* // Lab 2 -- Bank Account Class Wednesday 8 October, 2003 // Krstofer Evans, 10speed@ureach.com // CSCI 15A, Section 08 //*********************************************** public class bankAccount { // Import ConsoleReader ConsoleReader Console = new ConsoleReader(System.in); // Class variables private String name = null; // account holder's name. private String social = null; // Social Security Number. private String accountType = null; // type of account. private double balance = 0; // The balance for the account. private double interestRate = 0; // Interest Rate. private int yearOpened = 2003; // The year the account was opened. public double deposit = 0; public double withdraw = 0; // The Constructors. public bankAccount ( double aBalance, String aName ) { name = aName; balance = aBalance; } public bankAccount ( String aName, String aSocial, String aAccountType, double aBalance, double aInterestRate, int aYearOpened ) { name = aName; social = aSocial; accountType = aAccountType; balance = aBalance; interestRate = aInterestRate; yearOpened = aYearOpened; } public bankAccount() {} // Getter methods. public String getName() {return name;} public String getSocial() {return social;} public String getAccountType() {return accountType;} public double getBalance() {return balance;} public double getInterestRate() {return interestRate;} public int getYearOpened() {return yearOpened;} public double getWithdraw() {return withdraw;} public double getDeposit() {return deposit;} // Setter methods. public void setName(String newName) {name = newName;} public void setSocial(String newSocial) {social = newSocial;} public void setAccountType(String newAccountType) {accountType = newAccountType;} public void setBalance(double newBalance) {balance = newBalance;} public void setInterestRate(double aInterestRate) {interestRate = aInterestRate;} public void setYearOpened(int aYearOpened) {yearOpened = aYearOpened;} // The "Deposit" method: public double deposit( double deposit ) { balance = balance + deposit; return balance; } // The "Withdraw" method: public double withdraw( double withdraw ) { balance = balance - withdraw; return balance; } // The "Print Me" method: void printMe() { System.out.println("Your Current Name: " + name ); // prints user's name. System.out.println("Your Account Details: " + "\n\n"); System.out.println("Type of Account: " + accountType); // prints type of account. System.out.println("Year Opened: " + yearOpened); // prints the year the account was opened. System.out.println("Current Interest Rate: " + interestRate); // prints interest rate. System.out.println("Current Balance: " + balance); // prints current balance. System.out.print(""); } }