Here is my problem :

I am trying to model a growing city having different types of buildings.

The only deference between the buildings is the formula to calculate the cost necessary to go up one level.

in extremely simple it makes something like this :

class Building {

private int initialCost;

private << fucntion to calculate next level's cost>>;

private currentLevel;

public Building( int initialCost, ...

...

public int grow() // sould return the cost of the new constructiion and increment the level.

I would like to use the same class to model all the buildings. using the constructor to passe the growing function to the object

the growing function could be somthing like :

cost = initialCost * (level+2)

--or--

cost = initialCost ^level

--or--

anything like that. involving initialCost, the level, and possibly a few constants.

how whoul I define that variable ? how do I use it ? is this possible? how else could I do ?