Professional Documents
Culture Documents
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).
You can used the getOccupiedLocations() method; that should give you an array. Then get the size of the array via the size() method and thatll get you how many occupied spots there are. How can you obtain a count of the empty locations in a bounded grid? To get the amount of empty spaces available, youd need to get total amount of spots possible via getNumCols() times getNumRows() and subtract above number from the total you get.
2. How can you check if location (10, 10) is in a grid?
Grid is an interface and subsequently other classes have to supply such code. Where can you find the implementations of these methods? Other classes should implement such methods like AbstractGrid or BoundedGrid.
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).
4. All methods that return multiple objects return them in an ArrayList. Do you think it
would be a better design to return the objects in an array? Explain your answer. I dont think so. Arrays have a lot more baggage like having to state a lot of its components like size and locations and whatever entails such components.
2007 The College Board. All rights reserved. Visit apcentral.collegeboard.com (for AP professionals) and www.collegeboard.com/apstudents (for AP students and parents).