Why doesn't this work? I'm not sure what other information you would require apart from Formula is given by a char and an int which makes a type Term.
// returns true if f is identical to this Formula
// e.g. terms = {Term('C',2),Term('H',6)} and f = {Term('C',2),Term('H',6)} would return true
// but terms = {Term('C',2),Term('H',6)} and f = {Term('H',6),Term('C',2)} would return false
public boolean identical(Formula f)
{
int fSize = f.getTerms().size();
if(fSize!=terms.size())
{
return false;
}
else
{
for(int j = 0; j < fSize; j++)
{
Term tester = terms.get(j);
Term fTester = f.getTerms().get(j);
if(fTester == tester)
{
continue;
}
else
{
return false;
}
}
}
return true;
}
N.B. terms is the name of the ArrayList