danpost wrote...
I do not see a problem with the code you are showing here. However, I do not see the current code for the credit() method. Please show what you have there now (and remind me what class you have it in).

((Screen) getWorld().getObjects(Screen.class).get(0)).setText("Credit: " + n);
public class FiftyPence extends Money { private int n = 50; private long markTime = 0; GreenfootImage image = null;
public class Counter extends Actor { private int credit; private boolean moneyFound = false; /** * Act - do whatever the Counter wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { coinFound(); noteFound(); getCredit(); update(); } /** * Counting all Coins in Money class, which are inserted into the Coin Insertion. */ public void coinFound() { if (!moneyFound && !getWorld().getObjectsAt(517, 314, Money.class).isEmpty()) { moneyFound = true; List<Money> money2 = getWorld().getObjectsAt(517, 314, Money.class); Money money = money2.get(0); credit += money.getValue(); } if (moneyFound && getWorld().getObjectsAt(517, 314, Money.class).isEmpty()) { moneyFound = false; } } /** * Counting all Notes in Money class, which are inserted into the Note Insertion. */ public void noteFound() { if (!moneyFound && !getWorld().getObjectsAt(517, 314, Money.class).isEmpty()) { moneyFound = true; Money money = (Money) getWorld().getObjectsAt(517, 314, Money.class).get(0); credit += money.getValue(); } if (moneyFound && getWorld().getObjectsAt(517, 314, Money.class).isEmpty()) { moneyFound = false; } } /** * */ public int getCredit() { return credit; } /** * */ public void update() { GreenfootImage img = getImage(); img.setColor(Color.BLUE); ((Screen) getWorld().getObjects(Screen.class).get(0)).setText("Credit: " + credit); } }
private void credit() { GreenfootImage img = getImage(); img.setColor(Color.WHITE); img.drawString("Credit: " + n, 562, 531); }
((Screen) getWorld().getObjects(Screen.class).get(0)).setText("Credit: " + n);