Results 1 to 3 of 3
  1. #1
    javajen is offline Member
    Join Date
    Apr 2011
    Rep Power

    Default Need Help with Java

    Please help me with the following:

    1. Create a CreditCard class according to the UML Diagram on the back. It
    should have data fields that include an owner of type Person, a balance of type Money, and a creditLimit of type Money.
    2. It should have a constructor that has two parameters, a Person to initialize the owner and a Money value to initialize the creditLimit. The balance can be initialized to a Money value of zero. Remember you are passing in objects (pass by reference), so you have passed in the address to an object. If you want your CreditCard to have its own creditLimit and balance, you should create a new object of each using the copy constructor in the Money class.
    3. It should have accessor methods to get the balance and the available credit.
    Since these are objects (pass by reference), we donít want to create an insecure credit card by passing out addresses to components in our credit card, so we must return a new object with the same values. Again, use the copy constructor to create a new object of type money that can be returned.
    4. It should have an accessor method to get the information about the owner, but in the form of a String that can be printed out. This can be done by calling the toString method for the owner (who is a Person).
    5. It should have a method that will charge to the credit card by adding the
    amount of Money in the parameter to the balance if it will not exceed the credit limit. If the credit limit will be exceeded, the amount should not be added, and an error message can be printed to the console.
    6. It should have a method that will make a payment on the credit card by subtracting the amount of Money in the parameter from the balance.
    7. Compile, debug, and test it out completely by running (attached to this post)

    You should get the output:
    Diane Christie, 237J Harvey Hall, Menomonie, WI 54751
    Balance: $0.00
    Credit Limit: $1000.00
    Attempt to charge $200.00
    Charge: $200.00
    Balance: $200.00
    Attempt to charge $10.02
    Charge: $10.02
    Balance: $210.02
    Attempt to pay $25.00
    Payment: $25.00
    Balance: $185.02
    Attempt to charge $990.00
    Exceeds credit limit
    Balance: $185.02
    Attached Files Attached Files

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power


    This is not a code generation site. It is your homework so you must write it. Make an attempt, post your code here, post any error message(s) and ask a specific question.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Quote Originally Posted by javajen View Post
    1. Create a CreditCard class according to the UML Diagram on the back.
    Huh? There is no UML diagram on the backside of the lid of my laptop; some scratches, but they don't resemble a UML diagram by far. If you copy/paste your assignment text make sure you copy all of it.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts