ch.sahits.game.openpatrician.model.product
Class AmountablePrice

java.lang.Object
  extended by ch.sahits.game.openpatrician.model.BaseAmountable<IWare>
      extended by 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
 
Fields inherited from class ch.sahits.game.openpatrician.model.BaseAmountable
amount
 
Constructor Summary
AmountablePrice()
           
 
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()
           
 
Methods inherited from class ch.sahits.game.openpatrician.model.BaseAmountable
add, getAmount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sum

private long sum
Total price of all amounted items

Constructor Detail

AmountablePrice

public AmountablePrice()
Method Detail

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 added
avgPrice - 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.