Create a class named Restaurant
.
Restaurant
should define a primary single constructor that accepts three fields: a String?
(the name),
a String?
(the cuisine) and an Int
(the capacity).
You are welcome to name these fields however you like, and they should be private.
Your constructor should reject null
names and cuisines and negative or zero capacities.
You do not need to provide any getters and setters!
Instead, define a single method named equals
.
Your equals
method accepts an Any?
as a single parameter.
It should return true
if the passed object is a Restaurant
and has the same values for the name and cuisine,
and false
otherwise.
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: