This site requires JavaScript, please enable it in your browser!
Greenfoot back
ManiHallam
ManiHallam wrote ...

2012/9/7

Showing messages from Classes and updated messages from Counter

1
2
3
4
danpost danpost

2012/9/10

#
Please remove the last parenthesis from line 3.
danpost danpost

2012/9/10

#
This is how I ended up with the Money class code
import greenfoot.*;

public class Money extends Actor
{
    private int holdX, holdY;
    long markTime = 0;
    int value;

    public void act()
    {
        if (markTime == 0 && Greenfoot.mouseClicked(this))
        {
            holdX = getX();
            holdY = getY();
            if (value < 250) setLocation(517, 314); else setLocation (664, 367);
            markTime = System.currentTimeMillis();
        }

        if (markTime != 0 && System.currentTimeMillis() - markTime > 1000)
        {
            markTime = 0;
            credit();
            setLocation(holdX, holdY);
        }
    }

    private void credit()
    {
        ((Screen) getWorld().getObjects(Screen.class).get(0)).addCredit(value);
    }
}
and this is one of the Money sub-classes (FiftyPence)
import greenfoot.*;

public class FiftyPence extends Money
{
    public FiftyPence()
    {
        value = 50;
    }
}
All the other Money sub-classes should be similar.
ManiHallam ManiHallam

2012/9/10

#
sorry the server had problem, and I couldn't login
danpost danpost

2012/9/10

#
Dear ManiHallam, must go now. Will be back later on. Have a great day!
ManiHallam ManiHallam

2012/9/10

#
Thanks ever so much you too have a nice day
You need to login to post a reply.
1
2
3
4