ope.shopping
Class Person

java.lang.Object
  extended by ope.shopping.Person

public class Person
extends java.lang.Object

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

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

Constructor Summary
Person(java.lang.String name)
          Creates a new person object with given name.
 
Method Summary
 boolean chargeMoney(double amount)
          Charges some money from this person.
 double getMoney()
          Returns the balance of this person's bank account.
 java.lang.String getName()
          Returns the name of this person.
 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

Person

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

Parameters:
name - person's name
Method Detail

getName

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

Returns:
the name of this person.

getMoney

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

Returns:
the money this person has.

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.

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.