announcements‎ > ‎

2015-10-02 HW08

posted Oct 2, 2015, 11:36 AM by Samuel Konstantinovich   [ updated Oct 2, 2015, 1:57 PM ]
Write a bank account class as follows:

public class BankAccount{
    /*_________________
      Instance variables required:
      balance 
      accountID [the account number]
      username 
      password 
      pin
      _________________*/

    /*_________________
      1. A constructor: Should accept values for EACH of the instance variables
      2. A print method that shows all of the information at once.
      3. get methods for: balance, accountID, username
      4. set methods for: password, pin
      We do not set the balance, instead we use:
      5a. A method to deposit money into the account. It should accept an amount of money, and increase the account balance by that much and return true. This should not apply a negative deposit, instead leaving the balance unchanged and returning false. 
      6b. Method to withdraw money from the account and return true if it was successful, false otherwise. This will not be successful if the balance is too low, in which case the action does not change the balance. 
      6. A toString method that returns (tab separated): "Name\tAccount#\tBalance"

      7. A main method (included in the same file) to test your code. 
         Since withdraw and deposit return booleans, we can ... oops I haven't shown you if-statements yet. We will learn them Monday.
       hint:
       if( var.withdraw(1000) ){
            println("Withdrawal success!");
       }else{
            println("Withdrawal failure");
       }
      
      _________________*/
            
            

}
Comments