Unit 4 Quiz Answes - Quiz 4 Answers 1 Assume that...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Assume that Grid<Actor> grd has been initialized as a 10x10 bounded grid. Assume that Actor a1 has put itself in grd at location (2,2) and Actor a2 has put itself in grd at location (3,3). Assume that Actor a3 has been created but has not been placed in grd . What will be the result of the call a3.putSelfInGrid(grd, new Location(2,2)) ? Choose one answer. a. a3 will be added to grd at location (2,2) so that a call to grd.get(new Location(2,2)) will return the set of actors {a1, a3} b. a3 willl be placed in grd at location (2,2) after a1 has been removed from that location in grd. c. grd will not change because when an actor tries to place itself into a location already occupied by another actor, no change is made. d. The call will not compile; it should be a3.putSelfInGrid(grd, 2, 2) e. An exception will be thrown because a3 is trying toput itself into an already occupied location in grd. Correct 2 Make the same assumptions about grid grd and actors a1 and a2 as for the previous question. What will be the result of the call a2.putSelfInGrid(grd, a1.getLocation()) ? Choose one answer. a. The call will not compile; it should be a2.putSelfInGrid(grd, a1.getRow(), a1.getCol()) b. An exception will be thrown because an actor that has already been added to a grid with a call to putSelfInGrid cannot be added to a grid again (unless it has been removed). c. Actor a1 will be removed from grd and actor a2 will removed from location (3,3) in grd and placed in location (2,2) in grd, changing its own location to (2,2) d. Actor a2 will be removed from location (3,3) in grd and added to location (2,2) in grd with its own location changed to (2,2). A subsequent call to
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/30/2010 for the course BIOLOGY BIOLOGy taught by Professor Hued during the Spring '10 term at Eastern Oregon.

Page1 / 4

Unit 4 Quiz Answes - Quiz 4 Answers 1 Assume that...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online