CS 1110 Summer 2008 h/w 2 ... due Thursday 17th July

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, do start early.


  1. Elaborate on the banking Account and Economy material from class to build a simple model of a small economy, being careful to exploit as much privacy and security as you can at this stage. Your main method (in the Economy class) should allow for a reasonable test run of your economic model. You should create classes for People, Things, Shops, and Banks, and aim to build a simple program to allow People to buy Things from each other or from Shops, with everyone using bank Accounts to deal with money (ie, no cash). People should be allowed to both save and borrow money (but only from Banks, having distinct accounts for saving and borrowing. We will re-visit this question in a couple of weeks to enhance it, so it would be worth thinking ahead when desigining your solution.


  2. This question focusses on writing methods to manipulate arrays (all arrays will be arrays of doubles). You should write a program which has a class Matrix and a class Vect having appropriate fields, methods and constructors to do each of the following, testing it by having a main method which instantiates some Matrixes and Vects, applying these methods to them. You should arrange either that Matrix inherits from Vect or vice versa, whichever you decide is the most appropriate. (Notice that it might make sense to create additional methods to help out, for example a method to compare two arrays and return a boolean depending on whether or not they have the same length.)

    You should test your program by allowing the entry of numerical arrays from a test file you build called testdata.txt, and displaying the results on the screen.