CS 100JH Autumn 2005 h/w 2 ... due Monday 26th September

The point of these questions is to end up with as short a main method as possible by delegating as much of the work as possible to reusable methods, and to learn to write classes. Considering how much you'll probably have to spend thinking and making sense of these questions, I decided to ask only two.

  1. Build a banking system. We will probably revisit this later to add some more sophisticated security, but for now you should treat this as an apportunity to play with classes. You should have a class Bank to manufacture banks (and have at least two bank objects contructed), a class Person to make people (and have several different people built), a class Shop to make shops (have at least three shops), a class CredCardCo to make credit card companies (have at least two such companies), a class Employer to make employers (have at least two employers, and consider the possible relationship with the companies already built; think inheritance), and any other classes that you think might be helpful.

    You should include such fields and methods as make sense to model the interactions amongst these entities, for example, salaries, purchases, loans, accounts. You should also consider how to ensure reasonable privacy of information (we'll investigate this topic later in the course in rather greater depth), viable approaches to authentication (passwords would be a start ...), and good consistency of data (spending money should result in a transfer of money from the spender to the receiver!). Note that typically a credit card company will charge a percentage (usually in the range of 3% to 5%) on the stated purchase price (thus giving less to the receiver) as a way of getting income. You should design your classes and overall testing program so that it's easy to modify any of the main ingredients (e.g., change interest rates).