So I'm writing a program for school and it involves having two objects of Time (t1 and t2). which have hours, mins, secs. One method is to compare the two to see if they are equal. In my driver file its supposed to be like "t1.equals(t2);" and compare the two. within the method how do I get it so that the program "knows" to compare the variables from t1?
Heres what I have now but this is before I realized that its not supposed to be "equals(t1,t2);" but IS supposed to be "t1.equals(t2);"
public boolean equals(Time one, Time two)
{
boolean areEqual=true;
int timeOneSecs=one.getSecs();
int timeOneMins=one.getMins();
int timeOneHrs=one.getHrs();
int timeTwoSecs=two.getSecs();
int timeTwoMins=two.getMins();
int timeTwoHrs=two.getHrs();
if (timeOneSecs!=timeTwoSecs)
{
areEqual=false;
}
if (timeOneMins!=timeTwoMins)
{
areEqual=false;
}
if (timeOneHrs!=timeTwoHrs)
{
areEqual=false;
}
return areEqual;
}
I'm just not sure how to get the program to know which two times to compare if the first one is calling the second? (if that makes sense).