ElDiabloConCaca
U.S.D.A. Prime
I've got a project due next week that I'd like a little help on. I've managed to get about 90% of the project done, but two methods are stumping the hell out of me. Here's what the instructor wants:
And the methods I need to write are:
public Comparable findMin() {}
and
public Comparable findMax() {}
It would be great if I could do this without search trees or binary what-have-yous, since we haven't learned that yet. In the class are two privates:
private Object[] myArray;
private int myCt;
And myArray[] is an array containing Objects (which are all Integers (a wrapper for a primitive type)).
Can someone please help me with this? I'm assuming he'd like us to implement compareTo, but every time I try to do that, it fails saying it doesn't understand the compareTo command. I had it working once by casting (Comparable) onto some of the objects, but it really didn't work -- it just compiled correctly.
Anyway, thank you in advance!
=My instructor says:]Return the minimum object in this vector. You may NOT assume all elements are Comparable objects, BUT you may assume that all comparable objects in this vector are of the same class. If no Comparable object exists in this vector, return null.
And the methods I need to write are:
public Comparable findMin() {}
and
public Comparable findMax() {}
It would be great if I could do this without search trees or binary what-have-yous, since we haven't learned that yet. In the class are two privates:
private Object[] myArray;
private int myCt;
And myArray[] is an array containing Objects (which are all Integers (a wrapper for a primitive type)).
Can someone please help me with this? I'm assuming he'd like us to implement compareTo, but every time I try to do that, it fails saying it doesn't understand the compareTo command. I had it working once by casting (Comparable) onto some of the objects, but it really didn't work -- it just compiled correctly.
Anyway, thank you in advance!