I am doing this AntFarm project for my Java class. This project consists of different classes(Food, WorkerAnt, Queen) and they interact with each other using a interface(with a method called process).
http://ljhs.sandi.net/faculty/volger/apajava/GridWorld/Assignments/AntFarm/ – project
I’m currently stuck on the processActors() method in WorkerAnt. (It’s almost at the bottom of the page.)
The current code is the following:
public void processActors(ArrayList<Actor> actors) {
for (Actor nextActor : actors) {
nextActor.process(this);
}
}
The error I get is the following.
Cannot find symbol symbol: method process(WorkerAnt)
Going by the linked assignment,
Actordoes not have aprocess(WorkerAnt)method.Instead, this is part of the
Processableinterface (and thusFood).As such, make sure your
Actoris anActorimplementingProcessable(for example aFood).Ideally you’d change your
processActors(ArrayList<Actor> actors)method to be something likeprocessProcessables(ArrayList<Processable> processables).However, I see in the assignment that you are required to implement a
processActors(ArrayList<Actor> actors)so you can’t really do this (although I’m going to call this out as bad design – it’s akin to having a methoddivide(object, object)instead ofdivide(double, double)).To see why it is bad design, the assignment says
Except
Actors don’t haveprocessmethods –Processables do, andActors are notProcessable.In any case, you will have to settle for the fact that you expect some
Actors to beProcessables and do something like this:However, you should have realised this from the assignment: