I have a method that adds selected actors to the world. Each time you add one you lose money. Each actor subclass has a different cost. I have a getCost() method that should return the cost, but I am not sure how to access it from the world subclass. This is in my world code.
This is the getCost() method in my parent actor class.
And heres an example of what I've put in my subclasses.Any help would be greatly appreciated
public void onTouchDown(int x, int y) { System.out.println("You clicked on (" + x + ", " + y + ")"); Actor bob = newActorOfSelectedType(); add(bob, x, y); reduceMoney(getCost()); }
public int reduceMoney(int spend) { total = total - spend; if(total <= 0) { return 0; } else { return total; } }
protected int cost = 0; public int getCost() { return cost; }
public Minnow() { cost = 3; }