Results 1 to 2 of 2
  1. #1
    JavaB is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default Credit() crediting customers account

    I need help figuring how to create a credit(double amount) method that credits a customerís account. It should not directly access the balanceOwed field, but use the charge() method with a negative number.

    XML Code:
    public class Customer {
    	private int customerID;
    	private double creditLimit;
    	private double balanceOwed;
    	private double Amount;
     * 3-arg constructor that creates a new customer
    public Customer (int customerID, double creditLimit, double balanceOwed){
    	this.customerID = customerID;
    	this.creditLimit = creditLimit;
    	this.balanceOwed = balanceOwed;
    	//adding the amount to the current balance owed.
    	public void charge(double amount ){
    	//a credit that credits a customer's account
    	public void credit(double amount){
    		this.Amount = amount;

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Credit() crediting customers account

    That sounds like it could work. Have you tried it? You will have to replace the current credit() method because the new one you want takes the same arguments and the compiler would not allow that.

    The charge class should not allow that sneaky way of changing the amount. It should test for valid values and throw an exception for invalid values.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Credit Limit Calculator
    By Nightcrawler in forum New To Java
    Replies: 5
    Last Post: 03-05-2012, 03:49 AM
  2. limit disk space for my customers accounts
    By mtz1406 in forum Java Servlet
    Replies: 6
    Last Post: 04-04-2010, 05:38 PM
  3. Masking a credit card value
    By Samurai Coder in forum New To Java
    Replies: 2
    Last Post: 12-02-2009, 10:05 PM
  4. Java Project for extra Credit
    By Ankiel24 in forum New To Java
    Replies: 5
    Last Post: 04-24-2009, 10:56 AM
  5. Credit Card Validator
    By bluegti02 in forum New To Java
    Replies: 2
    Last Post: 06-17-2008, 07:09 AM

Posting Permissions

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