Answer_with_explanation.docx - Interface Creature function Move end function function Breed end function Class Ant function Move grid =char[10[10

Answer_with_explanation.docx - Interface Creature function...

This preview shows page 1 - 3 out of 4 pages.

Interface Creature function Move end function function Breed end function Class Ant function Move grid =char[10][10] ant.dir= ‘’ if(beetle.dir == N ) then ant.dir == S endif if(beetle.dir == W ) then ant.dir == E endif if(beetle.dir == E ) then ant.dir == W endif if(beetle.dir == S ) then ant.dir == N endif if (noBeetle > 1) then Move ant in direction of noBeetle if (beetle.dir == N && beetle.dir = W && beetle.dir = S && beetle.dir = E ) Choose forest beetle endif endif if(grid =char[row][col] is occupied) then No move end if end function function Breed action = “” if(noSurvived == 3) then action =breed
Image of page 1
end if for(int i=0;i<10;i++) for(int j=0;j<10;j++) if(grid[i][j]== “” ) then grid[i][j]=ant else action=noBreed end if End of InnerLoop End of OuterLoop end function Beetle function Move grid =char[10][10] beetle.dir= ‘’ if(ant.dir == N ) then beetle.dir == S endif if(ant.dir == W ) then beetle.dir == E endif if(ant.dir == E ) then beetle.dir == W
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 4 pages?

  • Fall '19
  • Jane Doe

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors