Problem Solving Assignment 10

Due: Tuesday, March 10th, 11:59 pm



You will be designing the first part of a Class for this PSA.

This homework requires skills from all Chapters up to Chapter 11.

  1. CreditCard -- Write a class the represents a credit card. This included the picture logo as well as account details (balance, history, etc.).

Details

You must put a comment at the top of your code that specifies, for both you and your partner, your: real names, login names, and PIDs, And a two to four sentence description of the program (one description for each program).

Use a multi-line comment (/* */).

Comments Comments in the style detailed in the book ARE required. Your code must be properly commented to receive full credit.

You must observe an 80 column limit. No line of your program may be longer than the 80th column on the screen.

IMPORTANT: Code that does not compile and run will receive a low score on this assignment. It is your responsibility to ensure it compiles and runs properly on lab machines.

CreditCard

In this assignment you will create a CreditCard Class with the following features.

Member variables:

You are responsible for creating class constructors appropriate for the member variables.

You will create accessing methods for your member variables.

  • For every member variable - create two methods:

    You will create a toString method which takes no parameters and returns a String.

  • Make your toString method match output provided below in testing class section below.
  • To format a double value to always show 2 decimal places you can use:

    Testing your method (in an application): For this assignment, you MUST use our tester application. You may download it here. We recommend you review the testing application prior to starting the assignment - it will help you in understanding what is required of you.

    The output should match the output below exactly. (You can use the output to determine default values, etc.)


    > java CreditCardTester
    James Dean
    0000 0000 0000 0000
    Expires: 1/1/2000
    Your balance is: 0.00

    Jamaal Lewis
    1234 2345 3456 4567
    Expires: 12/1/2009
    Your balance is: 12.50

    Invalid Number provided: 1234 2345 3456
    Setting to default value: 0000 0000 0000 0000
    Number is expected to be a String of 16 digits composed of
    4 groups of 4 digits separated by a whitespace.

    Invalid Number provided: 1234234534564567
    Setting to default value: 0000 0000 0000 0000
    Number is expected to be a String of 16 digits composed of
    4 groups of 4 digits separated by a whitespace.

    Invalid Number provided: a123 bc2d 2222 3233
    Setting to default value: 0000 0000 0000 0000
    Number is expected to be a String of 16 digits composed of
    4 groups of 4 digits separated by a whitespace.

    Invalid Expiration Month provided: 13
    Expiration Month is set to default: 1
    Expiration Month between 1 and 12 expected

    Invalid Expiration Day provided: 32
    Expiration Day is set to default: 1
    Expiration Day between 1 and 31 expected

    Invalid Expiration Year provided: 1934
    Expiration Year is set to default: 2000
    Expiration Year later than 1950 is expected

    Jamaal Lewis
    9876 6543 4321 2345
    Expires: 12/1/2009
    Your balance is -12.50

    Minimal testing passed

    How to turnin your homework electronically

    When you are ready to turn in your homework, first open a terminal window by right clicking on the empty area of your computer's desktop (have to use lab computers or remotely connect from your home computer using SSH or Putty) and select "Open a New Terminal". Then, run bundlePSA10 from your PSA10/bookClasses directory. Files are required to be submitted for PSA10:

    If you don't have one of these files present or have misspelled the name of one of these files, the bundle script will complain! Here you can see how you can run these commands:

    -bash-2.05b$  cd ~/PSA10/bookClasses 
    
    -bash-2.05b$  bundlePSA10 
    
    Good; all required files are present:
    
    	CreditCard.java
    
    Do you want to go ahead and turnin these files? [y/n] y
    
    OK.  Proceeding.
    
    
    Performing turnin of approx. XXXX bytes
    Copying to /home/linux/ieng6/cs8f/turnin.dest/cs8wxx.PSA10
    .
    Done.
    Total bytes written: XXXX
    Please check to be sure that's reasonable.
    Turnin successful.
    
    
    

    Make sure the Turnin is successful, otherwise we won't receive your submission! . If you want to make changes after you've turned in your homework, make the changes and run bundlePSA10 again. The program will warn you that a "previously turned-in file exists" and ask if "you wish to over-write this existing file". Respond in the affirmative by typing y and pressing the Enter key.

    Getting your interview done INDIVIDUALLY

    10% of your grade on this assignment will come from an interview you will have with one of the tutors during Open Lab Hours. You have 48 weekday hours after the electronic turnin deadline to get your interview done. The deadline for the interview for PSA10 is Thurs March 12th (theoretically at midnight, but actually by the end of the last tutor hour scheduled). Remember, the tutors may be busy after 4pm helping CSE8B students

    You get an interview by going into B260 during a scheduled tutor hour. Find the tutor, ask them if you can interview for the 8A PSA. If they have others who are waiting for interviews, your name will go on the end of the list of people waiting. Interviews take about 5 minutes each. It is your responsibility to go in early enough that you can get your interview completed. If everyone waits until the last hour on Thurs, this will not work.

    For the interview you will need to have a copy of your team's assignment in your account. If you are using your partner's account to submit the files, make sure you email them to yourself and save them under your account so that you have them available for the interview. The tutor will ask you to log in, change to the directory where your work is and then to follow their directions. They will ask you to run your program to show that it works, open files in Dr. Java (or your favorite editor), and ask you questions about HOW your code works. Additionally, they may question you as to how you would (theoretically) make small changes to the program to have it do something slightly different. You will not actually be required to change your code.

    Learning to be able to explain your problem solving process and discuss code with another human being is a very important professional skill. We hope that this process will help you develop this skill.