Page 66 - AP Computer Science A, 7th edition
P. 66
Which method described above corresponds to someMethod? (A) mirrorVerticalLeftToRight
(B) mirrorVerticalRightToLeft
(C) mirrorHorizontalTopToBottom
(D) mirrorHorizontalBottomToTop (E) mirrorDiagonalRightToLeft
Refer to the following for Questions 37 and 38.
A word creation game uses a set of small letter tiles, all of which are initially in a tile bag. A partial implementation of a TileBag class is shown below.
public class TileBag {
//tiles contains all the tiles in the bag private List<Tile> tiles;
//size is the number of not-yet-used tiles private int size;
//Constructors and other methods are not shown. }
Consider the following method in the TileBag class that allows a player to get a new tile from the TileBag.
public Tile getNewTile() {
if (size == 0) //no tiles left return null;
int index = (int) (Math.random() ∗ size); size--;
Tile temp = tiles.get(index);
/∗ code to swap tile at position size with tile at position index ∗ / return temp;