CS230 Data Structures, Wellesley College

Assignment 3

Due: Thursday, March 13, hard copy in class

[CS230 Home Page] [Syllabus] [Assignments] [Documentation] [CS Dept.]

Inheritance and GUIs

In the previous two assignments we gave you some description of the tasks you had to implement. In this assignment, you will more of a designer: you will be asked to design your programs while deciding which methods you should define and implement.

You should work in a neat way, and make a different folder containing the programs related to each task. By the date this is due, you should copy your folders into your own cs230-drop directory. You should make sure that you have included everything and that you do not attempt to edit your files past the due date.

Task 1: Create your own Bank!

Or at least the basic software that will deal with account creation, deposits and withdrawals. Below are the rules that were given by the management, a Wellesley graduate with CS230 experience. Because of that, her rules are carefully worded: Almost every sentence has some coding implication or hint. You really do not want to disappoint her -- read carefully!

Design and implement 3 classes – Account, CheckingAccount, and SavingsAccount. Note that CheckingAccount is-a Account, and the same is true for SavingsAccount. This observation has some implication for the way you design these three classes. Nobody ever creates just an Account. They can only create a SavingsAccount or a CheckingAccount. The Account class, includes an account number, an account balance, a deposit method and a method to print itself. It also includes a withdraw method, which however has no specific code associated with it!

Deposits work the same way no matter what kind of account you deposit to: the deposited amount simply is added to its balance. The management needs to make sure that no other code can override this method! In order to create a new account, some initial deposit is required. Then, the program will generate a random 5 digit account number. To print the contents of an Account, you should display the account number and the balance in a nicely formatted way.

A CheckingAccount class has in addition a minimum balance and overdraft fee. Its withdraw method allows overdrafts; however the overdraft fee is incurred if the balance drops below the minimum balance. When printing a CheckingAccount, you should display everything the Account displays plus the minimum balance. Use the Account display method to do most of the work. In particular, you should not need a NumberFormat object in this method.

The SavingsAccount has no such things as minimum balances and overdraft fees, but it has an annual interest rate. It also has a method to recalculate the balance every month by adding the monthly interest to its balance. (Assume that this method is only called once a month, no need to keep track of time.) Since the interest rate is annual, make sure to calculate the monthly interest accordingly. The class also has a method to display everything the Account displays plus the interest rate. Here also you should use the Account display method to do most of the work and you should not need a NumberFormat object.

To show that you have done your work correctly, you should create a driver class to instantiate and exercise each of the account types.

Task 2: GUI for Grad Schools

In a previous assignment you created a program that would rank Grad Schools according to some arbitrary characteristics. In this one, you will create a GUI that will help a user enter a few schools into the Grad Schools collection, and then using a slider will figure out which one is the best in the Overall category.

Your GUI has a tabbed layout with two tabs: One to add schools in the collection to be evaluated (tab "Add School"), and one to rank them according to the weights provided by the user (tab "Evaluate"). Here is the first tab's look – and feel free to improve on it:

adding a school - interface

When your program starts, the above tab appears. The user can enter the name of a school and three numbers that correspond to the perceived rates of the school in these three areas. When the user clicks the "Add School" button, the information is entered and a message appears at the bottom panel announcing what the program read.

A few hints could be very useful here:

When the user is done entering (some of) the schools, she can move on to the second tab to evaluate the schools in the overall category. For example, when the user selects 3, 4, 5 for weights in the three categories, this is what the GUI displays:

results of slider

Note that this is consistent with the top result you got in the previous assignment.

Extra Credit: Improve on the GUI

In case you finished this assignment early and wanted to go beyond the required tasks, here are some ideas to think about:

  1. The GUI above shows only the top school; change it to display the top-3 winners.
  2. You could have 3 more tabs, one for each of the categories "Academics", "Research" and "Publications".
  3. Have another tab "Schools" that contains a listing of all the schools in the collection so far.

Etc. And above all, start early, have fun and *think* before implementing!