Animals
Здравейте, може ли помощ 2-ри ден се мъча и няма резултат 33/100
https://pastebin.com/DjgWKr2C
https://judge.softuni.bg/Contests/Compete/Index/473#8
Problem 1.Animals
Create a hierarchy of Animals. Your task is simple: there should be a base class which all others derive from. Your program should have 3 different animals – Dog, Frog and Cat. Let’s go deeper in the hierarchy and create two additional classes – Kitten and Tomcat. Kittens are female and Tomcats are male! We are ready now, but the task is not complete. Along with the animals, there should be a class which classifies its derived classes as sound producible. You may guess that all animals are sound producible. The only one mandatory functionality of all sound producible objects is to produceSound(). For instance, the dog should bark.
Your task is to model the hierarchy and test its functionality. Create an animal of all kinds and make them produce sound.
On the console, you will be given some lines of code. Each two lines of code, represents animals and their names, age and gender. On the first line there will be the kind of animal, you should instantiate. And on the next line, you will be given the name, the age and the gender. Stop the process of gathering input, when the command “Beast!” is given.
Output
- On the console, print for each animal you’ve instantiated, its info on two lines. On the first line, print:
{Kind of animal} {name} {age} {gender} - On the second line, print: {produceSound()}
Constraints
Each Animal should have name, age and gender
All properties’ values should not be blank (e.g. name, age and so on…)
If you enter invalid input for one of the properties’ values, throw exception with message: “Invalid input!”
Each animal should have a functionality to produceSound()
Here is example of what each kind of animal should produce when, produceSound() is called
Dog: “BauBau”
Cat: “MiauMiau”
Frog: “Frogggg”
Kittens: “Miau”
Tomcat: “Give me one million b***h”
Message from the Animal class: "Not implemented!"
Examples
Input |
Output |
Cat Macka 12 Female Dog Sharo 132 Male Beast! |
Cat Macka 12 Female MiauMiau Dog Sharo 132 Male BauBau |
Frog Sashky 12 Male Beast! |
Frog Sashky 12 Male Frogggg |
Frog Sashky -2 Male Beast! |
Invalid input! |