Sunday, May 1, 2011

Steve, the animal collector.

Hi! Welcome to my blog. This is my first post and i'm trying to help Steve.

Steve is a lover of animals. He collects spiders, cats and fishes, so he is trying to make a program to help to manage his collection.
The first information is that the spiders, cats and fishes are animals. Every animal has a number of legs (8, 4 and 0 respectly). This let me to build the main classes like that:


In the chart, I created an Abstract class called Animal and it has only one atribute(integer legs). The operations are the Constructor, the get and set of legs. The other three classes are the spider, fish and cat. They also has their own Constructors.

Another information is that generaly an animal can walk and eat, even though each one do it in a different way. This information tell me that in the program they have two more operations and they could be different for each animal. That's the reason for the animal class is abstract.

Cats and Fishes are given a name and both are pets. Spiders are not named and neither do considered pets. Each pet could be named and play with him. Pets play in a different form and we could know which is their name.

Now is needed a new class, the pet class. It's conformed by Fishes and Cats. They need an atribute name and the operations getName, setName and play. The class diagram is taking that form:The last thing is that Steve may have many animals. This allow me to know that an Animal list is going to be used. And it also need some operations: Add, Read, Update and Delete. The constructors of the list are atached to the class too.

The Complete Diagram class of the program.
Steve's Animals.

No comments: