I have been asked to create a method hasHad(aDrug). The method specification is: If the receiver is linked to aTreatment object that is linked to aDrug then returns true; otherwise returns false. The method I tried to come up with is:
Drug is a class already created.public boolean hasHad(Drug aDrug) { if (treatments.contains(aDrug)) { return true; } else { return false; } }
aTreatment is used in another methoed in the same class as hasHad() - both in Patient class, and is used as such:
public void addTreatment(Treatment aTreatment)
Treatment is a class aready created.
My porblem is I don;t kniow if what I have done is correct as the rest of the classes are incomplete so I can't test it. I need to be sure if its right - or wronf, in which case I need help to correct it, before I move on.
Any help will be appreciated