Tuesday, May 10, 2011

First Actor subclass



First off, from last week, our system admin and Mr. Elkner has taught us a very important lesson when it comes to problem solving, the analogy RTFM. Basically, all we had to do to create,edit and play around in greenfoot was to “save a copy as” of the given greenfoot classes in a folder on your own computer.

After playing around with what was given to us, the wombat and leaf actors, we decided to create our own actor, Man. Studying the wombat subclass, we were able to edit it and make the man eat the wombat, much like the wombat eats the leaves. Then we stationed the man at some points on the grid, and as the wombat travels around and runs into the man, it will be eaten. One thing that we learned doing this is that if you put multiple wombats on top of each other on the same grid location and run them (act()), once they both run into the man class, one of the wombats will escape while the other is eaten. We also put a leaf and man on the same grid location and once the wombat reaches that location, the man eats the wombat before the wombat eats the leaf. However, if there are many wombats stacked that go over the man class, one of the wombats will actually eat the leaf and escape without getting eaten.

 Before:

 After:

No comments:

Post a Comment