Challenge: Modeling a Farm
00:00 So as always, if you don’t practice it, you don’t really understand it. It’s all fine and well to watch slides and nod and say, yeah, yeah, that makes sense. But until you actually have to write it yourself from scratch, things don’t really click. Your challenge is to model a farm.
You don’t want to let things go ahead of yourself, but you do want to try and use all the tools that you’ve learned so far. So here’s a suggestion. Model four classes, say one
Animal class and then three classes that inherit from
Each class should have a few attributes and at least one method, maybe making sounds, eating, sleeping. Maybe they should be variations for the classes that inherit from the
Animal class. Then try and model two more classes, maybe a
Field, maybe a
00:47 Maybe these can even have a parent class.
Then make these places have an attribute where they can store
Animal objects. So you’re starting to model a farm where you may have cows in one field and then you move them to the barn, and maybe the barn already has some pigs and some horses.
01:06 Maybe you feed the animals with other classes that can represent foods. Maybe each animal has a level of hunger and enjoyment. Get creative with it. But again, don’t get carried away with it.
01:21 But try and put into practice everything you’ve learned in this course so far.
Become a Member to join the conversation.