ope.shopping2
Class Customer

java.lang.Object
  extended by ope.shopping2.Customer

public class Customer
extends java.lang.Object

This class represents a Customer who has a name and some money.

Version:
0.2
Author:
Kimmo Kiiski, Teemu Koskinen
See Also:
ShoppingCart

Constructor Summary
Customer(java.lang.String name)
          Creates a new customer object with given name.
 
Method Summary
 boolean chargeMoney(double amount)
          Charges some money from this person.
 boolean checkOut()
          Checks out the person's shopping cart if he or she has sufficient amount of money.
 void clearCart()
          Empties the customer's shopping cart.
 double getBalance()
          Returns the balance of this person's bank account.
 ShoppingCart getCart()
          Returns the customer's shopping cart.
 java.lang.String getName()
          Returns the name of this customer.
 void receiveMoney(double amount)
          Adds the given amount of money to this person's bank account.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Customer

public Customer(java.lang.String name)
Creates a new customer object with given name. His/her bank account balance will be initially zero.

Parameters:
name - the customer's name
Method Detail

getName

public java.lang.String getName()
Returns the name of this customer.

Returns:
the name of this customer.

getBalance

public double getBalance()
Returns the balance of this person's bank account.

Returns:
the money this person has without changing it.

receiveMoney

public void receiveMoney(double amount)
Adds the given amount of money to this person's bank account.

Parameters:
amount - the amount of money to be given.

checkOut

public boolean checkOut()
Checks out the person's shopping cart if he or she has sufficient amount of money.

Returns:
boolean value indicating if checking out succeeded.

chargeMoney

public boolean chargeMoney(double amount)
Charges some money from this person. The bank account of this person will be charged for the amount of money, but only if the person has enough money. So, if the person doesn't have enough money then the account balance will remain unchanged.

Parameters:
amount - the amount of money to be charged.
Returns:
whether the charge was successful.

getCart

public ShoppingCart getCart()
Returns the customer's shopping cart.

Returns:
the shopping cart object of this customer.

clearCart

public void clearCart()
Empties the customer's shopping cart.