You've gone back in time to 500BC Athens and Socrates wants you to build him an app to help classify animals.
- Build the classes Animal, Cat, and Bug.
- Define the properties "color" and "leg_number" on the relevant and necessary classes. Have them be initialized within a constructor.
- Add the functionality that would allow us to call a method "move" with the Cat and Bug classes. Have the method return a string "I'm moving with " + leg_number + " legs!", with the "leg_number" being leg_number as set on the class.
- Add a new class called Bird. Add the property "wing_number". Add the functionality that would allow us to call a method "move" with the Bird class. Have the method return the string "I'm moving with " + leg_number + " legs!" if wing_number doesn't have an applicable value. If wing_number does have an applicable value, return the string "I'm flying".
You've gone back in time to 500BC Athens and Socrates wants you to build him an app to help classify animals.
- Build the classes
Animal,Cat, andBug.- Define the properties
colorandleg_numberon the relevant and necessary classes. Have them be initialized within a constructor.- Add the functionality that would allow us to call a method
movewith theCatandBugclasses. Have the method return a string"I'm moving with " + leg_number + " legs!", with theleg_numberbeingleg_numberas set on the class.- Add a new class called
Bird. Add the propertywing_number. Add the functionality that would allow us to call a methodmovewith theBirdclass. Have the method return the string"I'm moving with " + leg_number + " legs!"ifwing_numberdoesn't have an applicable value. Ifwing_numberdoes have an applicable value, return the string"I'm flying".
The code works fine. However, I am concerned about whether I should have used an interface or an abstract class instead of a superclasssuper class. I'm not sure I understand how to determine which to use when. If I should have used something different, can you explain and tell me how I should be implementing the move method or the properties?