Alright, so as always, this is for school. Here is my exercise:
Exercise 137 Add a customized equals method to the Car class, defined below, so that it returns true if and only if the model identification of the argument is the same as that of the Car object whose instance method is being called. public class Car { private String myModel, myColor; public Car( String color, String model ) { myColor = color; myModel = model; } public String getModel() { return myModel; }
// add your equals method here
This is where my code would go.
} public class MainClass { public static void main( String[] args ) {
My code would also go here.
} } What happens when your new equals method is applied to an argument that is an instance of Object or one of its subclasses, but not a Car object? Suggest a way to overcome this problem.
Alright, I feel like a jerk for posting this previously so I'm sorry, but basically, here's my question. I'm pretty sure it would return true or false. So, if it does, am I supposed to take the instance of one class and sort of poly-morph it to make it fit the instance of another class or am I just supposed to make a new class all together.
Thx, ghostheadx