Exercise: Getting started with the creature simulator

This code contains an application that creates an little framework for simulating creatures. A creature is basically just an object that has some properties (like position, direction, speed, color, ...) and behavior. It can act - change its properties and it knows how to render itself on a graphical canvas. In this lab version, a creature has also a vision. It can see other creatures within certain field of view and a certain distance.

The framework is built on the top of Java Swing library.

Starting with the creature simulator

Create a new Java project in Eclipse

Correctly place the given source files

Make sure you have no errors in the Problems view

Go over the classes to get the notion about how it works

Exercise 3: A generic toString() method

In the creature simulator's AbstractCreature class from the previous lab write a generic toString() method:

public String toString() {...}

which will output all of the creature's attributes (fields). It has to be generic method since subclasses of the AbstractCreature can define their own attributes this class is not aware of.

Think what is the difference between getDeclaredFields() and getFields()

To test it, you can add some more attributes to the SmartCreature

Exercise 4: Smart creature

The goal of this exercise is to create a new kind of creature is a bit smarter than the stupid one.
It should have following behavior:

It should try to align its speed with the speed of the creatures around.

It should go in the same direction as the creatures around.

It should maintain some minimal distance from the creatures around.

Exercise: Code analysis of the creature simulator

The given code is not well written. Now you will play a role of a senior software developer whose task is to review a code that has been produce by some junior. Try to come up with as many improvements as possible. For example:

What to do with some of the utility functions?

What to do with the fact that logic of the Environment and the visualization are kept together?

...

Appendix

Coordinates and Angles

Overview of the coordinate system. We use the common Euclidian two-dimensional geometry with the coordinate system origin in the middle of the plane.