- Work with class
Animal
. - Provide it with 3 private fields - color(
String
), numberOfPaws(int
), hasFur(boolean
). - Add constructor with full parameters. Save the parameter order and names as it is listed in a second paragraph.
- Add a methods
getDescription()
, witch would use class fields and return a string with such pattern "This animal is mostly(color)
. It has(numberOfPaws)
paws and('a'/'no' -> depends on value of hasFur)
fur." - (Optional) In the method
getDescription()
change the word 'paw' depending on thenumberOfPaws
: number of paws is 1 -> 'paw', number of paws is different from 1 -> 'paws'.
- Work with classes
Dog
andBird
. Extend them with the help ofAnimal
. - Create no-args constructor for each where provide all necessary information for
Animal
constructor bysuper()
method:- for
Dog
:color
- brown,numberOfPaws
- 4,hasFur
- true; - for
Bird
:color
- blue,numberOfPaws
- 2,hasFur
- false.
- for
- Override
getDescription()
method for classBird
: add one more sentence to the description. The result must be "This animal is mostly blue. It has 2 paws and no fur. Moreover, it has 2 wings and can fly." - (Optional) Create an object of each class and call
getDescription()
method for both of them. Try to explain the output results.