Yesterday I was attemptingposted my first solution to get help with a problem that many people assumed was a homework question. In fact it is an interview problem here. And before you say it, yes, I I am now aware that I have many weak spots in Java and need to do extensive review before tackling any more interviews. Having said that, piecing together what people on here mentioned, I have come to what I hope is a good solution.
If you're concerned about giving help or advice for an interview question, please know that I have already submitted my proposed solution. Any help on here now is too late for this interview, but hopefully honing in on what I should have done here prepares me better for future problems.
If Iand am somehow breaking the rules with this submission, please tell me what I needasking to do so that I won't be breaking the ruleshave it reviewed again.
So hereHere is the problem:
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 "
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 theCatandBugclasses. Have the method return a string "I'm moving with<number of legs>legs!", with the "<number of legs>" beingleg_numberas 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 theBirdclass. Have the method return the string "I'm moving with<number of legs>legs!" ifwing_numberdoesn't have an applicable value. Ifwing_numberdoes 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 "
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 theCatandBugclasses. Have the method return a string "I'm moving with<number of legs>legs!", with the "<number of legs>" beingleg_numberas 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 theBirdclass. Have the method return the string "I'm moving with<number of legs>legs!" ifwing_numberdoesn't have an applicable value. Ifwing_numberdoes have an applicable value, return the string "I'm flying".