View Single Post
  #3 (permalink)  
Old 01-06-2008, 01:25 PM
roots's Avatar
roots roots is offline
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
It ain't ruby !!
You can achieve this using call back, mess of codes ..

Code:
public class Main { double initialCost ; CostCalculator cost1 ; CostCalculator cost2 ; Main(){ cost1 = new CostCalculator(){ @Override public double Calculate(double initialCost) { return initialCost * 2 ; } }; cost2 = new CostCalculator(){ @Override public double Calculate(double initialCost) { return initialCost * 3 ; // What ever } }; } public double calculate(){ return cost1.Calculate(initialCost); // Plus extra stuffs if you have } }
If i have understood your problem correctly, this is one of the option you have got.
__________________
dont worry newbie, we got you covered.
Reply With Quote