Exercise 4: Creating a Simple Bank Package (Level 1 & 2)
In this exercise, you will create a development environment for the Banking project with src and classes directories. You will also place the Account class and TestAccount program into packages.
Figure 2-3 shows a UML diagram of the packages that you will create in this exercise. The Account class will be placed in the com.mybank.domain package and the TestAccount class will be placed in the com.mybank.test package.
![](fig2_3.GIF)
Figure 2-3. The package structure of the Banking Project
Preparation
There is no preparation for this exercise.
Task 1 - Creating the Development Directories
Create the development environment directories for the source and class
files as described in "Development" on slide 22 of Module 2.
Task 2 - Modifying the Account
Class
Using a text editor, modify the Account.java source file and place the class in the appropriate package. Move the Account.java source file into the appropriate development subdirectory.
Task 3 - Modifying the TestAccount
Program
Using a text editor, modify the TestAccount.java source file, place the program in the appropriate package, and include the appropriate imported classes.
Move the TestAccount.java source file into the appropriate development subdirectory.
Task 4 - Cleaning Up the Project Directory
Remove all class files and any backup files created by your text editor.
Task 5 - Compiling the TestAccount Program
On the command line, use the javac command to compile the test program and the Account class
.
Task 6 - Running the TestAccount Program
On the command line, use the java command to run the test program. The code has not changed, so you should still see the following output:
The final balance is 147.0