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

2014/1/20

Extending two classes/subclasses

cloudster101 cloudster101

2014/1/20

#
Hello, If I had two subclasses, for example pet and mammal, could I have another subclass like dog that would extend both Thanks, cloudster101
danpost danpost

2014/1/20

#
cloudster101 wrote...
If I had two subclasses, for example pet and mammal, could I have another subclass like dog that would extend both
In short, no; but if, let us say, 'pet' was an implementation and dog was made a subclass of mammal that implements pet, you would achieve what you are looking for.
davmac davmac

2014/1/20

#
No, you can't. If you make one of them an interface instead of a class, then it is possible to both extend the class and implement the interface, which is quite similar in effect (though you don't inherit method implementations from an interface). You can only ever extend one class, but you can implement as many interfaces as you like.
mohamed.talaat99 mohamed.talaat99

2014/1/20

#
Hello, i have a game contain many snakes and one person and house when person touch house i need to remove all actors in the world how can i remove all actors ? thanks
cloudster101 cloudster101

2014/1/20

#
Person Class
1
2
3
4
5
6
7
8
9
10
public void act()
{
if(isTouching(house.class))
{
removeObject(snake)
removeObject(person)
removeObject(house)
}
 
}
davmac davmac

2014/1/20

#
mohamed.talaat99 wrote...
Hello, i have a game contain many snakes and one person and house when person touch house i need to remove all actors in the world how can i remove all actors ? thanks
Please start your own topic for this question.
You need to login to post a reply.