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

2018/4/26

Making a text box with random numbers

myeongil myeongil

2018/4/26

#
Was wondering if anyone could help me out with a project I'm currently making in computer programming. I'm making a counting game for the little kids in my school, and the goal here is to make a text box appear with a randomized number inside it; the number representing the amount of an object (in this case, I'm using pennies). I'm hoping that the kids would drag pennies to an area, which are then counted, and that the child succeeds when the number of pennies dragged, equals the number that was randomized inside the text box. I already have code for the dragging and counting, what's killing me is the box that should have a random number, as well as checking if the counted number equals the randomized number. As you can probably tell, I'm pretty new to this.
danpost danpost

2018/4/26

#
My Value Display Tutorial scenario should help as far as the text box is concerned. The counting of pennies in the target area should be done in a static field (set to zero by world constructor) in the Penny class. Each penny should keep track of their state of being in the target area or not and adjust the counting field when moving in and out of that area (as well as updating its retained state. The retaining of the state is needed to tell when the state actually changes. The number that is randomly chosen to be in the text box will need to be retained by the world so that the comparison can be made with the values of the two fields.
You need to login to post a reply.