ch.sahits.game.openpatrician.model.product
Class AmountablePrice
java.lang.Object
ch.sahits.game.openpatrician.model.BaseAmountable<IWare>
ch.sahits.game.openpatrician.model.product.AmountablePrice
- Type Parameters:
T - IAmountable implementation that is is collected hereby called item
public class AmountablePrice
- extends BaseAmountable<IWare>
This class defines the amounted price of an IWare object.
Each object in the real world has hits unique price. Since no instances of the
objects are used but only one reference the price information gets lost. The
amountable price tracks the average price of all amounted objects
- Author:
- Andi Hotz, (c) Sahits GmbH, 2011
Created on Nov 20, 2011
|
Field Summary |
private long |
sum
Total price of all amounted items |
|
Method Summary |
void |
add(int amount,
int avgPrice)
Add a number items |
int |
getAVGPrice()
Retrieve the average price of one item |
void |
remove(int amount)
Remove a number of items |
String |
toString()
|
sum
private long sum
- Total price of all amounted items
AmountablePrice
public AmountablePrice()
getAVGPrice
public int getAVGPrice()
- Retrieve the average price of one item
- Returns:
add
public void add(int amount,
int avgPrice)
- Add a number items
- Parameters:
amount - number of the items to be addedavgPrice - average price of one item that is added
remove
public void remove(int amount)
- Remove a number of items
- Overrides:
remove in class BaseAmountable<IWare>
- Parameters:
amount - of items to be removed
toString
public String toString()
- Overrides:
toString in class BaseAmountable<IWare>
Copyright © 2011-2012 Sahits GmbH. All Rights Reserved.