历年AP Computer Science计算机科学系列
2016 AP Computer Science A Free-Response Questions Free Download
2016 AP 计算机科学A简答题部分免费下载
此套题仅 Section II含有简答题，
1）This question involves the implementation and extension of a RandomStringChooser class.
- A RandomStringChooser object is constructed from an array of non-null String values. When the object is first constructed, all of the strings are considered available. The RandomStringChooser class has a getNext method, all of the strings are considered avaible. The RandomStringChooser chosen string from the available strings in the object. Once a particular string has been returned from a call to getNext, it is no longer available to be returned from subsequent calls to getNext. If no strings are available to be returned, getNext returns "none".
The following code segment shows an example of the behavior of RandomStringChooser.One possible output is shown below. Because sChooser has only four strings, the string "NONE" is printed twice.Write the entire RandomStringChooser class. Your implementation must include an appropriate constructor and any necessary methods. Any instance variables must be private. The code segment in the example above should have the indicated behavior (that is, it must compile and produce a result like the possible output shown). Neither the constructor nor any of the methods should alter the parameter passed to the constructor, but your implementation may copy the contents of the array.
- The following partially completed RandomLetterChooser class is a subclass of the RandomStringChooser class. You will write the constructor for the RandomLetterChooser class.The following code segment shows an example of using RandomLetterChooser.The code segment will print the three letters in "cat" in one of the possible orders. Because there are only three letters in the original string, the code segment prints "NONE" the fourth time through the loop. One possible output is shown below.Assume that the RandomStringChooser class that you wrote in part (a) has been implemented correctly and that getSingleLetters works as specified. You must use getSingleLetters
appropriately to receive full credit.
Complete the RandomLetterChooser constructor below.
2016 AP Computer Science A 计算机科学FRQ简答题完整版答案免费下载