Create a method named order
.
order
should accept a single parameter, a Restaurant?
to order from, and return a String
, a comment on your
order.
Depending on which subclass of Restaurant
it is, you should respond differently:
Fancy
restaurant—for instance, with name
"MIGA"—you should order "At MIGA I'll order
something
inexpensive"FastFood
restaurant, for instance, with with name
"Chipotle"—you should order "At
Chipotle I'll order
something healthy"Vegan
restaurant, then it will have a String
property cuisine you can retrieve
using getCuisine
.
For example, if it its cuisine is "Thai" and name
is "Vegan Delight", you should order "At Vegan Delight I'll
order delicious Thai
food".All Restaurant
s have a name that you can retrieve as the property name
.
If the restaurant is null
or not one of the kinds described above, return null
.
Do not solve this problem using method overloading.
And do not hard-code the answers.
Your solution should work for any Fancy
, FastFood
, or Vegan
instance.
Note that we are not implying that there are not fancy vegan restaurants or fancy fast food restaurants or vegan fast-food restaurants. If anything, the ability of real entities to resist strict classification is one of the limitations of Kotlin's object model.
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: