10-02-2013 - HW

posted Oct 3, 2013, 7:45 AM by Samuel Konstantinovich   [ updated Oct 3, 2013, 7:45 AM ]
Continue yesterday's lab:
You should have the following methods already:

BankAccount(name,account,PIN,password,balance)
deposit()
withdraw()
setPIN()
setPassword()
setName() 
setAccount() 
setBalance()
toString() the format should be something easy to read like:

Account Holder: Bruce Leeroy
Account #: 123456789
PIN: 1234
password: shogun
balance: 1337.00

1. Place your name/period as a block comment at the top of the file. 

2. Modify your BankAccount class with these new rules: (Think about how you made your class, and if your design makes these changes easier or more difficult)

  • The account number should be an integer and it should only be set to a 9 digit number (some value between 100000000 and 999999998), if the parameter is invalid, set the account number to 999999999 and print a message to the screen about the problem.
  • The PIN should only be set to a n integer that is 4 digits number (some value between 1000 and 9998), if the parameter is invalid, set the PIN to 9999 and print a message to the screen about the problem.
  • Change withdraw so that if the account does not have enough money OR the parameter is negative: a) nothing is changed, b) an error message is printed and c) false is returned. If the account does have enough money, then the amount is deducted and true is returned.
  • Change deposit so that when the parameter is negative: a) nothing is changed, b) an error message is printed, and c) false is returned. Otherwise deposit the money and return true.
  • Write an authenticate method that takes as parameters an account number and a password, and returns true if the two match the BankAccount object and false otherwise.

3. Write a main() method as the last method in your class. Use it to test all of your methods via terminal output.


4. Place the completed file on the dropbox in a folder caled HW4.


Comments