问题描述:

Guys could you help explain me the last 2 lines please

MenBook mbobject = (MenBook) other

does it mean that mbobject is an object of the class Menbook? and what does the Other mean?

 public boolean moreExpensiveThan(Object other) {

If(other == null)

return false;

else if (getClass() != other.getClass())

return false;

else { MenBook mbobject = (MenBook) other;

return (sellingPrice() >= mbobject.sellingPrice());

}

Please note that OrderedByPrice is an interface

网友答案:

You are assigning to variable mobject (of type MenBook) the object other (of type Object), after checking that its type is of the correct one (getClass() != other.getClass()).

网友答案:

You are creating a new MenBook object called mbObject and you assign the object called other to it.

The (MenBook) in front of other means you are casting the object called other to a MenBook object.

相关阅读:
Top