Overview of practical

The assignment is to design and write a proof of concept program for a credit union. The requirements are to show that the foundational concepts are valid. Not all required items may be used in the program. Later, someone else will modify the code and write the complete system consisting of hundreds of classes. This program will store a few members, print and write a log of the information to a file for others to review later.

This isn't expected to be a complete example of all the programming concepts learned over the entire semester. It will be an example of how well the concepts of interfaces, inheritance, file IO and a few other java features can be incorporated into the task below.

The requirements are broken into two levels:

  • Level 1: Interface, Inheritance, ArrayList storage and printing objects
  • Level 2: Writing the objects to a file with exception handling

UML of classes - see the legend: see image.

Level 1: Requirements

For each of the classes created, include a header formatted in Javadoc style that includes the class name - purpose, "Practical 4", your name, and this exam's year & term (i.e. 2205).

Common interface

  • Defined as an interface, per UML
  • Contains constants specifying a number for options that may apply to the member.
    • PRIMARY_MEMBER = "P"
    • SECONDARY_MEMBER = "S"
    • SAVINGS = 1
    • CHECKING = 2
    • UNKNOWN = -1

(For fewer points: If the interface is not working, place the constants in the Member class)

Member class

  • Uses the Common interface, per UML
  • Member class contains the following attributes: (accessors or mutators are not required)
    • name - The member's name. For example: Jane S. Doe
    • id - A 5-digit numeric id for the member
    • memberType - a String containing the type of the member (primary or secondary) from Common
    • defaultAccount - one of: CHECKING or SAVINGS from Common
  • Member default constructor:
    • set name and memberType to "Undefined"
    • set id, and defaultAccount to UNKNOWN
  • Member parameterized constructor:
    • has four parameters: _id, _name, _memberType, and _defaultAccount
  • toString() method returns text as shown below with attribute values replacing items in the "[ ]":
Member [id]:[name] is a [memberType] member.
The default account is a [checking|savings] account.
  • The id should be a five digit number, with leading zeros as necessary. Either "checking" or "savings" should be printed depending on the patient's accountType option. For example:
Member 35309:Jane S. Doe is a primary member.
The default account is a checking account.

Member 05927:John Q. Public is a secondary member.
The default account is a savings account.

Primary class

  • Define the Primary class as a subclass of Member for primary members, as shown in the UML diagram. The Primary class contains one additonal attribute, balance, describing the balance in the default account that the member owns. For example: "50000.00". An accessor and mutator are not required
  • The Primary constructor requires four parameters: _id, _name, _defaultAccount and _balance. The Primary parameterized constructor calls the super class constructor with:
    • _id, _name, _defaultAccount
    • Plus _membertype - use the constant for the PRIMARY_MEMBER
  • Use parameter _balance to set the Primary member's balance attribute
  • toString() method returns text as shown below with attributes values replacing items in the "[ ]":
Primary [Member’s toString()]
The member’s balance is [balance].
  • For example:
Primary Member 05927:John Q. Public is a primary member.
The default account is a savings account.
The account balance is $50,000.00.
  • Note: the underlined text was a result of the Member's toString() method.

Secondary class

  • Define the Secondary class as a subclass of Member, per UML. The Secondary class contains one attribute, authorized, describing whether this member is allowed accessthe name of the patient's child, if known. An accessor and mutator are not required
  • The Secondary constructor requires four parameters, _id, _name, _defaultAccount and _authorized. The Secondary parameterized constructor calls the super class constructor with:
    • _id, _name, and _defaultAccount
    • _memberType - Use the constant for Secondary members
  • Use parameter _authorized to set the secondary member's authorized attribute
  • toString() method returns text as shown below with attributes values replacing items in the "[ ]":
Secondary [Member’s toString()].
The member is authorized: [authorized].
  • For example:
Secondary Member 35309:Jane S. Doe is a secondary member.
The default account is a checking account.
The member is authorized: yes.
  • Note: the underlined text was a result of the Member's toString() method

CreditUnion class

  • Must have the main() method
  • Must have a single ArrayList to hold both the Primary and Secondary objects
  • Must create Primary and Secondary objects according to the table given below
    • Hard code the object creation. Do NOT use any keyboard input
  • Add the Primary and Secondary objects to the ArrayList
  • Must print report heading for Members as shown in output, note spacing
  • Print all the Members from the ArrayList
  • Must count the Primary objects as they are being printed
  • Must count the Secondary objects as they are being printed
  • Must print the summary counts as shown
  • Members to be added to the array list:

Member ID Name Default Account Balance / Authorized
Primary 00886 Robert J. Smith Savings 129,325.56
Secondary 13817 Sally R. Schultz Checking yes
Primary 06707 Judith A. Barth Checking 2,748.90
Secondary 36198 Diane C. Baker Savings no
Primary 58409 James T. Kirk Savings 378,457.94

Expected output - shown as first run: "Creating" the file. Next run Adding to (See Level 2, below)

Patient report:

Primary Member 00886:Robert J. Smith is a primary member.
The default account is a savings account.
The account balance is $129,325.56

Secondary Member 13817:Sally R. Schultz is a secondary member.
The default account is a checking account.
The member is authorized: yes.

Primary Member 06707:Judith A. Barth is a primary member.
The default account is a checking account.
The account balance is $2,748.90

Secondary Member 98234:Diane C. Baker is a secondary member.
The default account is a savings account.
The member is authorized: no.

Primary Member 58409:James T. Kirk is a primary member.
The default account is a savings account.
The account balance is $378,457.94

Primary members: 3
Secondary members: 2

Level 2: Requirements

Must complete all Level 1 requirements

Add to the existing CreditUnion class

  • Must define a constant for the output filename, Members.txt
  • Determine if the output file exists:
    • If file exists, print: Adding to the current file Members.txt In this case duplicate data will be appended to the file
    • If the file does not exist, print: Creating a new file Members.txt
    • In both cases, print the filename using the constant. Do not hard code the filename in the print statement
  • Must open the output file in either append or create (replace) mode
  • When printing to the screen, as in level 1, print the same information to the output file, for level 2 - both level 1 and level 2 output must match!
  • Must properly close the output files
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.