Lab Assignment #9: Classes

Due by 11:59PM on Friday, April 16.


DRAFT - to be finalized by 4/9/99

Reading Assignment

Read about classes in Chapter 8 of the text.


In-Lab Work

A Class design for a Bank

In the lab this week, we are going to design a class hierarchy for a simple bank account structure. You will extend the same program you write for the in-lab exercise for the actual lab assignment. The basic problem has to do with bank accounts. Think of a bank account as an individual object. What are the most important data properties? What types of operations would you have on these data? In the lab, you will design a simple bank account class that can store just the basic information on that account - the account balance. Write a class BankAccountLab with the following features:

  1. The class should have a data variable called balance which cannot be accessed from any other classes. (So what type of protection should you use?)
  2. The class should have the following constructors:
  3. The class should also have the following methods:

Save this program as BankAccountLab.java


Lab Assignment

NOTE!

To test your classes, you will need a main program to drive all your classes. I have created a main program that tests out all your methods. You should make sure your classes work with this main program. Do not change this main program. We will be using a main program like this one to test your code. If your parameters are not in proper order, make sure you order them according to how the main program expects it. The account number is treated as a string in this main program.

Download BankMain.java


For the lab, we will start with the basic lab assignment that you have created, and will make a number of changes. There are two sets of implementations that you will need to do - the first set you should be able to do by 4/13, since everything you need will be covered in the lab and lecture. The second set requires inheritence, which would be covered in class on (4/13). Of course, nothing is due until 4/16, but you should still work on the program this week, since it is significantly easier than lab 8.

The following sets of enhancements are to be made to the program:

  1. First set:
  2. Second set:

Submitting Your Lab Assignment

For this lab, you should submit three files: BankAccount.java, SavingsAccount.java, and CheckingAccount.java

Attach these files to an e-mail sent to a201@cs.indiana.edu with lab9 as the subject.