Anthill

  • 8
  • Locked
There are three classes of ants in our anthill: Queen, Soldier, and Worker. There is a single queen for the entire anthill. Her populate method creates tens of soldier ants and hundreds of worker ants. Add code to the main method: - send all the worker ants in the workers array to find food (sendFor
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Travis McKinstry Backend Developer at ThoughtWorks
21 January, 15:38
for(int i = 0; i < workers.length; i++){
    if(i + 1 < soldiers.length){
        soldiers[i].sendIntoBattle();
    }
    workers[i].sendForFood();
}
The above works and satisfies the requirements, however, the task says it doesn't.
Jcode
Level 26 , United Kingdom
14 January, 17:57
for (int i = 0; i < workers.length; i++) {
            Worker worker = workers[I]; // I don't get why we need this line????
            worker.sendForFood();
        }
I'm not sure what the difference is with the solution below
for (int i = 0; i < workers.length; i++) {
            //Worker worker = workers[i];
            workers[i].sendForFood();
        }
Any ideas?
Travis McKinstry Backend Developer at ThoughtWorks
21 January, 15:38
Yeah, I believe most of these exercises expect something very specific, even if it works. It's a problem. What you have should work.
Anonymous #10844609
Level 23 , India, India
13 October 2021, 06:24
Hi, Can someone help to know why the task is failed ?