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

2017/3/8

Logic with Classes

gurgi414 gurgi414

2017/3/8

#
Is there a way to go logic with classes? For example could you say if this class is in this overarching class then do blah. If this is possible please respond. Furthermore if there is a way to do this with objects that would be great if you could let me know.
Super_Hippo Super_Hippo

2017/3/8

#
I am not sure what you mean. In general, a class A should only extend another class B if A is in fact some kind of B. So for example a bullet should never extend a gun because a bullet is not a gun. Another thing is that you should not create a new class for every object like Counter1, Counter2, LifeCounter27 or whatever. Instead, just create some instances of one class.
gurgi414 gurgi414

2017/3/8

#
Could you say for example could I say: if Class 1 = Overarching Class do blah, would that evaluate as true?
Nosson1459 Nosson1459

2017/3/9

#
You can't use the equal operator for classes if that 's what you're asking. You should probably use 'instanceof'.
You need to login to post a reply.