CPSC 120B Programming Assignment #4

Credit Cards

Due Wednesday, December 11 by noon

In this assignment you will write a class that models a credit card and a driver program to use the class.

Your CreditCard class must have the following instance data:

The class must have the following public instance methods:

The CreditCard class should also have the following static method:

The Driver Program Your driver program will read in a credit card number, instantiate a credit card, let the user charge things to the credit card (as long as the user wishes or until the credit limit is reached), display the bill and let the user make a payment. The user can then go back and charge more and so on. All input/output in the program will be done using dialog boxes (look at the last exercise in Lab 11). The main program should use the three support methods listed below. Here is a rough outline of the main method:
         get the credit card number (call the method validCCNum to do this)
         if the number is not valid
            display a message telling the user he/she is suspected of credit 
            card fraud (or something equally scary)
         else  // the number is valid
         {
            read in the credit limit and annual interest rate
            instantiate a CreditCard object
            
            do
            {
                let the user charge things (call the method makeCharges to do this)
                let the user make a payment (call the method makePayment to do this)
            }
            while the user wants to continue
          }
The three support methods used by main are as follows:

NOTE: As usual use good programming style and good programming habits!!! Do not try to type everything in at once -- do the program incrementally. Use good variable names and proper indentation and white space. Be sure to include brief documentation for each method you use!

Hand In: A printout of each file (CreditCard.java and class that uses it) and tar your directory containing the program and email it to me.