Animals Practice Task
In the tutorial you have just finished you produced classes to represent different crops and through the tasks learned about object-oriented programming concepts including:
Now is a good time to pause, catch our breath and practice what we have discovered.
In the next section we will start developing a class to represent the fields that exist on a farm. These fields can contain crops (which we already have classes for) and animals. We will need to create classes to represent these animals.
The class diagram for animals is:
Notice that for an animal to grow it requires a particular amount of:
This is similar to the crop, which required food and light. Particular animals may have there own specific requirements and may grow in different ways.
Using the above information create the necessary classes to enable you to create instances of:
Remember that cows and sheep can grow in different ways - you are free to develop your own algorithms for this.
Now that you have the required animal classes create a management menu similar to the one you developed in Task 7 to enable you to select and manage particular animals.
Back to the farm
Now that you have had a chance to consolidate your skills it is time to move forward with the farm and create a class to represent the fields that can exist on a farm.