Lab 5

Purpose

This lab introduces you to more advanced aspects of classes. These aspects include multiple constructors, method overloading, and interfaces. These aspects allow for more flexibility in writing classes, but also introduce new and exciting bugs. It is vitally important from here on out that you code a little, test, code a little more, test some more, etc... Otherwise, you will experience many unnecessary headaches.

In part 2 of this lab, you will have a chance to learn important debugging skills. Learning to debug effectively will save you hours of coding time.

Key Reading

  • 6.1-6.9

Introduction

Credit Card Account

The interview went very well with BYU Credit Union. They were impressed with your solution to the brain teaser you wrote previously. You have been hired to help with the creation of a new, basic credit card program. The program will perform basic account operations. The expectations for the project have been predetermined. Thus the credit union has written a test driver to make sure your program operates within their intended specifications.

Bugged Solution

Once you have the program complete, the credit union also wants you help a struggling colleague. The colleague has been working on the same project as you but could not quite finish the solution. The credit union would like you to fix the bugs in the colleague's code.

Requirements

Part 1 - Account management (20 points)

  • The Eclipse project you will need to complete this lab can be downloaded here This project includes CreditCardTestDriver.java and CreditCard.java. Do not modify these files in any way. Modifying CreditCardTestDriver.java will be considered an act of cheating.
  • Create a CreditCardAccount class that implements the CreditCard.java interface
  • An object of your CreditCard Account class must be able to be created:
    • with just an account name (set the initial balance of the account to $0.00 and the annual interest rate of the account to 20%)
    • with an account name, an initial balance, and a specifiable annual interest rate for the account
    • with just the initial balance and annual interest rate - set the account name to a random 16 digit number (of the form #### #### #### ####, with each digit being random)
  • Run the Credit Card test driver on your CreditCardAccount class
  • Pass the 7 tests contained in the driver (2 points per test, 20 for a complete set)

Part 2 - Bug off (10 points, 1 point for each bug fix)

  • Pass off Part 1 with a TA to obtain a bugged version of the file CreditCardAccount.java
  • Fix the 10 bugs in the file
  • Show a list of the bugs to a TA. Include in the list:
    • A description of the bug
    • The line number of the bug
    • How to fix the bug

Extra Credit - Account Interface (10 points)

  • Build a JFrame based Graphical User Interface (GUI) to accompany your credit card account simulator
  • Your GUI must allow user input of an account name, an initial balance, an annual interest rate, and a payment amount
  • A user can create a new account (by means of any of the three constructors), make a purchase using the current credit card account, make a specified payment on the account, or make a default payment on the account
    • Display the name of the credit card and the current balance
    • Each payment simulates one month. After each month display the new balance of the credit card account
  • A new account must be able to be created at any time without the program ending (an old account can be ignored after a new account is created)

Requirement Notes

Credit Card Account

  • Pay careful attention to spacing in the random account number
  • Annual Interest Rates are passed to constructors as percent values, not decimal decimal (e.g. 20, not .2)

Test Driver

  • The class name of the class that implements the interface must be CreditCardAccount for the driver to function properly

Debugging

  • Some of the errors are compile errors that must be fixed before the program can run. Others are run-time errors that must be fixed for proper functioning of the CreditCardAccount class.

GUI

  • In order to create any one of the three types of accounts, consider a separate button for each type of account
Designed by Andy Griffin