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

Comments for tut-access-p1

Return to tut-access-p1

A new version of this scenario was uploaded on Fri Jan 14 04:54:53 UTC 2011 Fix a bug in the Counter class.
A new version of this scenario was uploaded on Tue Jan 18 04:57:18 UTC 2011 Change the design a little.
A new version of this scenario was uploaded on Tue Jan 18 09:05:27 UTC 2011 Re-added source code.
It's... very...simple.
davmacdavmac

2012/7/5

It's... meant... to... be. It's... a... tutorial.
USER67USER67

2012/11/15

The code was great! thanks! Do you know to set a counter limit with a success message or perhaps a time limit? Thanks!
davmacdavmac

2012/11/15

Please ask on the forum (the "Discuss" link). :)
USER67USER67

2012/11/15

okay thanks mate
FEearlobeFEearlobe

2013/7/4

I<3disting
davecoolkiddavecoolkid

2013/8/27

Could you explain to me what this line of code does: Space spaceWorld = (Space) getWorld(); What do the parentheses mean when you put them around "(Space)"?
danpostdanpost

2013/8/27

'getWorld' return a World object (not particularly a 'Space' object; though it could be one). That is what '(Space)' does. It makes it a 'Space' object. This is called 'typecasting' and it informs the system to look in the 'Space' class for any methods or fields referenced with the World object. Any methods or fields that are declared in the 'Space' class would not be found otherwise.
davmacdavmac

2013/8/27

davecoolkid: as danpost says 'getWorld()' returns a 'World', but in the line of code you specify the variable is of type 'Space'. The compiler doesn't let you assign just a World to a Space variable (even though the World *might* be a Space). In this case we know that the world definitely *is* a space, so we use this type cast to tell the compiler that it's ok. A simple experiment you can do is to remove the type cast (the "(Space)" part) and try to compile. What happens?
davecoolkiddavecoolkid

2013/8/27

Thanks danpost and davmac for the clarification helped me out a lot.
CubeGamer6CubeGamer6

2017/4/24

Geez, i made a game myself much like this (as in space and stuff) and what suprised me after checking this page is that the space icon that is used here is IDENTICAL. It doesn't help either that the theme is much the same too. I'll just hope my teacher will believe that it is still original XD. Well, atleast i have a fancy movement engine.