mkdir ~/cs170/lab4 # make lab directory
cd /home/cs170001/share/labs/lab4 # Go to share folder with lab2
cp * ~/cs170/lab4 # Make a copy to your folder
cd ~/cs170/lab4 # Go back to your lab folder
Click Open in BlueJ
ls ~/cs170/lab4 >> BankAccount.java bluej.pkg
The bluej.pkg contain information used by BlueJ
harrysChecking.deposit(100);inside BlueJ , we do:
inside BlueJ , we do:
Since methods in a class implement functions, to augment the functionality of a class, we will have to add more methods to the class.
The addInterest() method does not return any value (now you know the return type).
Here is an example of its usage:
BankAccount harrysChecking = new BankAccount(); harrysChecking.deposit(1000); harrysChecking.addInterest(5);
The addInterest() with interestRate parameter equal 5 will add 5% interest to the current balance in harrysChecking
You were editing the class - so you don't have to open a new (edit) window, but you need to find this (edit) window:
Use what you have learn in class - see: click here
Also, look at the methods in BankAccount to get ideas, for example: deposit()
Java knows the precedence rules: multiply and divide go before addition and subtraction
After a correction, you must compile the class again !
If the value is incorrect, go to the edit window and fix the addInterest() method.
After fixing, you need to compile, and start the test all over again.
cd ~/cs170/lab4 /home/cs170001/turnin BankAccount.java lab4