exerciseFeb408

exerciseFeb408 - In both constructors, the role and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP202 Instructor: Ladan Mahabadi February 4, 2008 Ant Colony Write a class that represents an ant colony. In each ant colony, there’s one queen and the rest are categorized by the following tasks: Foraging Patrolling Nest Maintenance Midden Work 1 In your class, you need to represent each ant with: An identification mechanism: a 4-digit number assigned to each ant A role: each ant should belong to one the above categories (his role may change) A position: represented by x, y, z coordinates (which may vary) Your class should have: Constructors : One in which the identification number is assigned by the user One in which the identification number is generated randomly
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: In both constructors, the role and position of the worker are inputted as a parameter Modifier methods which allow Role modification of an ant Position modification of an ant Print method That displays the id, position, and role of an ant Main method In this method, create 5 ants using both constructors and then, using the print method, display each ants information to the user. Finally, ask the user for a new coordinate position, and move your favorite ant to that position and display its updated information. 1 Research by Deborah Gordon: http://www.ted.com/talks/view/id/145...
View Full Document

Ask a homework question - tutors are online