SimpleBank of Cornfield Hamlet+

OVERVIEW

This tiny bank supports about 20 families in Cornfield Hamlet; most are farmers. The bank has 1 employee who operates out of his house. The church took a collection and bought him a computer for Christmas, so he needs an application that will convert all the scraps of papers stacked in his den into neatly organized and searchable data. The user interface should be extremely easy and user friendly. Data must be password protected and encrypted as local children may use the computer to do their homework (only computer in the hamlet).

SUMMARY OF BANK ACTIVITIES

After interviewing the owner, these are the things he says his bank handles.

1. Internal Bank Accounts:

2. Customer Accounts:

3. Customer Services:

PROGRAM CLASS OUTLINE


// String.h is required.

class Date {
 private:
  unsigned char month; // unsigned char is smaller than int
  unsigned char day; // unsigned char is smaller than int
  int year;
 public:
  Date ( int month, int day, int year ); // constructor
  Date (); // standard constructor (allows a blank object creation)
  ~Date () { } // standard destructor, clear pointers
  int set_date ( int month, int day, int year ); // returns true if valid
  int get_month () { return (int) month; }
  int get_day () { return (int) day; }
  int get_year () { return year; }
  int is_valid_date (); // returns true if valid
}

// Example usage:
// Date * mydate = new Date ( 01, 18, 2005 );
// int tempday = mydate->get_day ();
// Date mydate2;
// mydate2.set_date ( 01, 18, 2005 );

class Address {
 private:
  String street_line1;
  String street_line2;
  String street_line3;
  String city;
  String state;
  String zip;
  String phone;
  String phone2;
  String fax;
 public:
  Address (
    String street_line1,
    String street_line2,
    String street_line3,
    String city,
    String state,
    String zip,
    String phone,
    String phone2,
    String fax
  ); // constructor
  Address (); // standard constructor (allows a blank object creation)
  ~Address () { } // standard destructor, clear pointers
  void set_address (
    String street_line1,
    String street_line2,
    String street_line3,
    String city,
    String state,
    String zip,
    String phone,
    String phone2,
    String fax
  );
  void set_street_line1 ( String street_line1 );
  void set_street_line2 ( String street_line2 );
  void set_street_line3 ( String street_line3 );
  void set_city ( String city );
  void set_state ( String state );
  void set_zip ( String zip );
  void set_phone ( String phone );
  void set_phone2 ( String phone2 );
  void set_fax ( String fax );
  String get_street_line1 ();
  String get_street_line2 ();
  String get_street_line3 ();
  String get_city ();
  String get_state ();
  String get_zip ();
  String get_phone ();
  String get_phone2 ();
  String get_fax ();
}

class Interest {
 private:
  single rate;
  String increment_period;
 public:
  Interest ( single rate, String increment_period ); // constructor
  Interest (); // standard constructor (allows a blank object creation)
  ~Interest () { } // standard destructor, clear pointers
  void set_interest ( single rate, String increment_period );
  void set_rate ( single rate );
  single get_rate ();
  String get_increment_period ();
}

class Ledger_Line {
 private:
  double lineid;
  Date when;
  float amount;
  String type;
  String note;
 public:
  Ledger_Line ( 
    double lineid,
    Date when,
    float amount,
    String type,
    String note
  ); // constructor
  Ledger_Line (); // standard constructor (allows a blank object creation)
  ~Ledger_Line () { } // standard destructor, clear pointers
  void set_ledger_line (
    double lineid,
    Date when,
    float amount,
    String type,
    String note
  );
  void set_lineid ( double lineid );
  void set_when ( Date when );
  void set_amount ( float amount );
  void set_type ( String type );
  void set_note ( String note );
  double get_lineid ();
  Date get_when ();
  float get_amount ();
  String get_type ();
  String get_note ();
}

class Customer {
 private:
  single customerid;
  Address address;
 public:
  Customer ( single customerid, Address address ); // constructor
  Customer (); // standard constructor (allows a blank object creation)
  ~Customer () { } // standard destructor, clear pointers
  void set_customer ( single customerid, Address address );
  void set_customerid ( single customerid );
  void set_address ( Address address );
  single get_customerid ();
  Address get_address ();
}

class Account {
 private:
  single accountid; // account number and unique id
  single customerid;
  String terms;
  String account_type;
  float balance;
  Interest interest;
  Ledger_Line* history;
  String* cosigners;
  String notes;
 public:
  Account ( 
    single accountid,
    single customerid,
    String terms,
    String account_type,
    float balance,
    Interest interest,
    Ledger_Line* history,
    String* cosigners,
    String notes
  ); // constructor
  Account (); // standard constructor (allows a blank object creation)
  ~Account () {  // standard destructor, clear pointers/arrays
    if ( cosigners ) {
     String* temp = cosigners;
     while ( *temp ) {
      delete *temp;
      temp++;
     }
     delete cosigners;
    }
    cosigners = NULL;
    if ( history ) {
     String* temp = history;
     while ( *temp ) {
      delete *temp;
      temp++;
     }
    delete history;
    }
    history = NULL;
  }
  int set_account (
    single accountid,
    single customerid,
    String terms,
    String account_type,
    float balance,
    Interest interest,
    Ledger_Line* history,
    String* cosigners,
    String notes
  ); // true if valid
  set_accountid ( single accountid );
  set_customerid ( single customerid );
  set_terms ( String terms );
  set_account_type ( String account_type );
  set_balance ( float balance );
  set_interest ( Interest interest );
  set_notes ( String notes );
  add_cosigners ( String cosigners );
  add_history ( Ledger_Line history );
  single get_accountid ();
  single get_customerid ();
  String get_terms ();
  String get_account_type ();
  float get_balance ();
  Interest get_interest ();
  Ledger_Line* get_history (); // returns an array with the last entry NULL
  String* get_cosigners (); // returns an array with the last entry NULL
  String get_notes ();
  int credit ( Date when, float amount ); // adds money to account
  int debit ( Date when, float amount ); // subtracts money from account
  float get_balance (); // returns current balance
  int transfer ( Date when, float amount, single accountid );
  void update (); // Increments interest
}

class Service {
 private:
  single customerid;
  String service_type;
  Date when;
  double fee;
  String notes;
 public:
  Service (
    single customerid,
    String service_type,
    Date when,
    double fee,
    String notes
  ); // constructor
  Service (); // standard constructor (allows a blank object creation)
  ~Service () { } // standard destructor, clear pointers
  void set_service ( 
    single customerid,
    String service_type,
    Date when,
    double fee,
    String notes
  );
  void set_customerid ( single customerid );
  void set_service_type ( String service_type );
  void set_when ( Date when );
  void set_fee ( double fee );
  void set_notes ( String notes );
  single get_customerid ();
  String get_service_type ();
  Date get_when ();
  double get_fee ();
  String get_notes ();
}

// automatic deposit/withdrawal accounts
class Automatic {
 private:
  single accountid;
  String external_name;
  String external_account;
 public:
  Automatic (
    single accountid,
    String external_name,
    String external_account
  ); // constructor
  Automatic (); // standard constructor (allows a blank object creation)
  ~Automatic () { } // standard destructor, clear pointers
  void set_automatic (
    single accountid,
    String external_name,
    String external_account
  );
  void set_accountid ( single accountid );
  void set_external_name ( String external_name );
  void set_external_account ( String external_account );
  single get_accountid ();
  String get_external_name ();
  String get_external_account ();
  void credit_account ( float amount ); // Adds to related internal account
  void debit_account ( float amount ); // Subtracts from related internal account
}

PROGRAM NOTES

The Account class could be further specialized into Savings, Checking, CDs, and Christmas Funds using inheritance, i.e. something like:

class Checking: public Account {
 private:
 public:
}

However, there were not enough differences between SimpleBank accounts to warrant it.

+ While there is a lot more here than required, I was trying to learn how to do things and included them for my own future reference. If you see something done incorrectly, please tell me. T@cattail.nu

Not submitted portion of this:
I've visions of the guy sitting on the porch in his rocker, sipping his home-brewed whiskey, nodding, and saying very slowly, "Yup... I offer dem surveeces but aint no one dat used em yut. I spect to figure out how to do em one day. Aint no rush roun' here. Cept durn harvest. Then we all rush. Dis yur gonna be good dough - see the colur of dat corn? Dat's a might fine corn crop comin'." I can even hear his voice - a nice, warm, low rumble. And he's got a couple bad teeth, but a very fine, worn out hat.