# Unit 1 Free Response Question (FRQ) Practice

Each coding exercise has its own folder. Open its `.java` file and press **Run** to try it. **Run Tests** checks every graded exercise in this lesson at once.

The AP CSA exam has 4 free response questions (FRQs) where you have to write Java code in 1.5 hours. The first FRQ is about Methods and Control Structures worth 7 points using expressions, methods, loops, and `if` statements in two parts (A and B). Students will write two methods or one constructor and one method of a given class based on provided specifications and examples. In Part A (4 points), the method or constructor will require students to write iterative or conditional statements, or both, as well as statements that call methods in the specified class. In Part B (3 points), the method or constructor will require calling String methods.

Although we have not yet covered enough to complete an FRQ, the following is an adaptation of the 2022 FRQ #1 part a about the points earned in a video game with 3 levels using the class `Level`. You will try the simplified version of the FRQ in this lesson using just expressions and method calls, and then you will do the complete FRQ part a in the next unit after you learn about `if` statements.

## FRQ Description of Level Class

This question involves simulation of a single-player video game. In the game, a player attempts to complete three levels. A level in the game is represented by the `Level` class which keeps track of their points in a level and whether they have reached the end or goal of that level.

```java
public class Level
{
    /* The number of points the user has in this level */
    private int points;
    /* Whether the goal of the level has been reached */
    private boolean goal;

    /** Constructor for the Level class */
    public Level(int p, boolean g)
    {
        points = p;
        goal = g;
    }

    /** Returns the number of points (a positive integer) recorded for this level */
    public int getPoints()
    { /* implementation not shown */ }

    /** Returns true if the player reached the goal on this level and returns false otherwise */
    public boolean goalReached()
    { /* implementation not shown */ }

    // There may be instance variables, constructors, and methods that are not shown.
}
```

## FRQ Practice

In this simplified version of this FRQ, you will declare 3 `Level` objects for the 3 levels of the game and then call their `getPoints()` methods to calculate the score for the game. The score is calculated by adding the points from each level, but in this version, level 2 points are doubled and level 3 points are tripled.

### Exercise 1

In the main method, declare 3 objects of the `Level` class called `level1`, `level2`, and `level3` with the following points and goals: 100 points and true, 100 points and true, and 200 points and true. Then, calculate the score for the game by adding the points from each level using their `getPoints()` method, but double the level 2 points and triple the level 3 points.

> Open the `01-frq-simple-game-score` folder and edit `Game.java`. Press **Run** to try it; **Run Tests** checks it (4 tests).
