Fiveable
💻AP Computer Science A
​

💻AP Computer Science A

FRQ 2 – Classes
​
Unit 3: Class Creation
AP CS A FRQ Types & Units

Each FRQ type tests specific skills taught in particular units. Here's why certain units appear for each question type:

FRQFocusUnitsWhy
FRQ 1Methods and Control Structures1-2Tests method writing, loops, conditionals - foundational programming from Units 1-2
FRQ 2Class Design3Tests class design, constructors, instance variables - all Unit 3 OOP content
FRQ 3Data Analysis with ArrayList4Tests using, analyzing, and manipulating data in an ArrayList - Unit 4 content
FRQ 42D Array4Tests 2D array traversal and manipulation - Unit 4 content

This mapping reflects College Board's exam structure - each FRQ type tests specific skills that are taught in particular units.

Practice FRQ 1 of 201/20

2. This question involves the GameSpinner class, which simulates a game spinner with a specific number of sectors. You will write the complete GameSpinner class, which contains a constructor and two methods.

GameSpinner objects are created by calls to a constructor with one parameter.

  • The parameter is an int that represents the number of sectors on the spinner. (Precondition: Assume that this value will be greater than or equal to 1.)

currentRun

The GameSpinner class contains a currentRun method, which reports the length of the current run of consecutive identical spin values.

  • Returns the current length of the run of consecutive identical spins.

  • If no spins have occurred, returns 0.

  • If the most recent spin value is different from the spin value immediately preceding it, the current run length is 1.

  • If the most recent spin value is the same as the spin value immediately preceding it, the current run length is incremented by 1.

Returns an int representing the length of the current run.

spin

The GameSpinner class contains a spin method, which simulates a spin of the spinner.

  • Generates and returns a random integer between 1 and the number of sectors (inclusive).

  • Updates the current run length based on whether the generated value matches the previous spin value.

Returns the random integer result of the spin.

Statement

Return Value

Explanation

GameSpinner g = new GameSpinner(4);

A GameSpinner object is created with 4 sectors.

g.currentRun();

0

No spins have occurred yet.

g.spin();

3

A random value between 1 and 4 is generated. Let's assume it is 3. The current run is now a sequence of one 3.

g.currentRun();

1

The current run length is 1.

g.spin();

3

Let's assume the random value is 3 again. The run of 3s continues.

g.currentRun();

2

The current run length is 2 (two consecutive 3s).

g.spin();

4

Let's assume the random value is 4. The run of 3s is broken. The new run is a sequence of one 4.

g.currentRun();

1

The current run length is 1.

g.spin();

4

Let's assume the random value is 4 again.

g.currentRun();

2

The current run length is 2.

Write the complete GameSpinner class. Your implementation must meet all specifications and conform to the examples shown in the table.

Timed

00:00

Response auto-saves






Pep

essential ap study content awaits..

Features
Testimonials
Testimonials
start studying →
FRQ Directions
Free Response Question Practice

This practice environment simulates the AP AP Computer Science A Free Response Questions section. Here are some guidelines:

  • Read each question carefullybefore responding. Pay attention to command verbs like "identify," "explain," "analyze," or "evaluate."
  • Use the timer to practice time management. You can pause, restart, or hide the timer as needed.
  • Mark for Review if you want to come back to a question later.
  • Your responses are saved automatically as you type. You can also use the drawing tool for questions that require diagrams or graphs.
  • Use the toolbar for formatting options like bold, italic, subscript, and superscript.
  • Navigate between questions using the Previous and Next buttons at the bottom of the screen.

Tip: Answer all parts of each question. Partial credit is often available, so even if you are unsure, provide what you know.