> For the complete documentation index, see [llms.txt](https://www.computersciencea.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.computersciencea.com/group/session-14.md). Agents can also search and read this documentation through its [MCP server](https://www.computersciencea.com/~gitbook/mcp).

# Session 14

## Source Code

```java
import java.util.*;

public class Session14 {
    public static void main(String[] args) {
        System.out.println("Session 14");

        // Menu
        System.out.println("Menu");
        System.out.println("E1 - Example 1");

        // setup Scanner
        Scanner in = new Scanner(System.in);
        System.out.print("Choice: ");
        String choice = in.nextLine();

        // switch choices
        switch (choice) {
            case "E1":
                System.out.println("Example 1");
                example1();
                break;
            case "E2":
                System.out.println("Example 2");
                example2();
                break;
            case "E3":
                System.out.println("Example 3");
                example3();
                break;
            case "E4":
                System.out.println("Example 4");
                example4();
                break;
            case "E5":
                System.out.println("Example 5");
                example5();
                break;
            case "E6":
                System.out.println("Example 6");
                example6();
                break;
            case "E7":
                System.out.println("Example 7");
                example7();
                break;
            case "E8":
                System.out.println("Example 8");
                example8();
                break;

        }
    }
    // example1 method
    public static void example1() {

    }

    // example2 method
    public static void example2() {

    }

    // example3 method
    public static void example3() {
        // Create Rectangle object using parameterized constructor

    }

    // example4 method
    public static void example4() {
        // first book
       
        // second book
        
        // third book
        

    }

    // example5 method
    public static void example5() {
        // create CollegeStudent object
        
        // call methods
        
    }

    // example6 method
    public static void example6() {
        // create CollegeStudent object
        

    }

    // example7 method
    public static void example7() {
        // create CollegeStudent object
        
    }

    // example8 method
    public static void example8() {
        // create two high school students
        
        // call printStudentCounter method
        

    }

}
```

## DefaultPerson.java

```java
/**
 * The Defaulter class represents an entity with basic personal attributes including
 * name, age, financial status, and driving eligibility.
 */
public class DefaultPerson {

    // The name of the individual
    

    // The age of the individual
    

    // The amount of money the individual has
    

    // A flag indicating whether the individual is eligible to drive
    

    /**
     * Gets the name of the individual.
     *
     * @return The name of the individual.
     */
    
    

    /**
     * Gets the age of the individual.
     *
     * @return The age of the individual.
     */
    
            

    /**
     * Gets the amount of money the individual has.
     *
     * @return The amount of money of the individual.
     */
    
    

    /**
     * Determines if the individual is eligible to drive.
     *
     * @return True if the individual is eligible to drive, false otherwise.
     */
    
    
}
```

## MyPhone.java

```java
/**
 * The MyPhone class represents a phone with a model name and price.
 * It includes a default constructor to initialize the phone's attributes
 * with default values.
 */
public class MyPhone {
    /** The model of the phone. */
    

    /** The price of the phone. */
    

    /**
     * Default constructor initializes the phone's attributes.
     * The model is set to "Unnamed" and the price is set to 100.0.
     */
    

    /**
     * Gets the model of the phone.
     *
     * @return the model name of this phone
     */
        

    /**
     * Gets the price of the phone.
     *
     * @return the price of this phone
     */
    
    
```

## Rectangle.java

```java
/**
 * The Rectangle class represents a rectangle with a length and width.
 * It provides methods to calculate the area and perimeter of the rectangle.
 */
public class Rectangle {

    /** The length of the rectangle */
    

    /** The width of the rectangle */
    

    /**
     * Constructs a Rectangle with the specified length and width.
     *
     * @param length the length of the rectangle
     * @param width the width of the rectangle
     */
    

    /**
     * Calculates and returns the area of the rectangle.
     *
     * @return the area of the rectangle
     */
    

    /**
     * Calculates and returns the perimeter of the rectangle.
     *
     * @return the perimeter of the rectangle
     */
    

}

```

## MyBook.java

```java
/**
 * The MyBook class represents a book with a title and a number of pages.
 * It includes multiple constructors to demonstrate constructor overloading.
 */
public class MyBook {

    /** The title of the book */
    

    /** The number of pages in the book */
    

    /**
     * Constructs a MyBook object with a default title and zero pages.
     * The title is set to "Untitled".
     */
    

    /**
     * Constructs a MyBook object with a specified title
     * and zero pages.
     *
     * @param t the title of the book
     */
    

    /**
     * Constructs a MyBook object with a specified title
     * and number of pages.
     *
     * @param t the title of the book
     * @param p the number of pages in the book
     */
    


}

```

## CollegeStudent.java

```java
/**
 * Class CollegeStudent keeps track of the name, email, and ID of a college student.
 */
public class CollegeStudent
{
    // private instance variables
    

    /**
     * Constructor for CollegeStudent.
     * @param name the initial name of the student
     * @param email the initial email of the student
     * @param ID the initial ID of the student
     */


    /**
     * Gets the name of the student.
     * @return the name of the student
     */


    /**
     * Gets the email of the student.
     * @return the email of the student
     */


    /**
     * Gets the ID of the student.
     * @return the ID of the student
     */


    /**
    * Returns a string representation of the CollegeStudent object.
    * @return a string representation of the CollegeStudent object
    */
    



    // Accessor methods (getters)

    /**
     * Sets the name of the college student.
     * @param name the new name of the student
     */
 
 

    /**
     * Sets the email of the college student.
     * @param email the new email of the student
     */



    /**
     * Sets the ID of the college student.
     * @param id the new ID of the student
     */
 
 

}

```

## Athlete.java

```java
import java.util.*;

/**
 * Represents an athlete in the high school's sports team management system.
 */
public class Athlete {
    // Private instance variables


    /**
     * Constructs an Athlete with specified attributes.
     * 
     * @param name     The name of the athlete.
     * @param grade    The grade level (9th, 10th, 11th, 12th).
     * @param sport    The sport the athlete participates in.
     * @param position The position in the sport (e.g., forward, goalkeeper).
     * @param height   The height of the athlete in inches.
     * @param weight   The weight of the athlete in pounds.
     */



    // Accessor (getter) methods

    /**
     * Gets the athlete's name.
     * 
     * @return The name of the athlete.
     */
   
   

    /**
     * Gets the athlete's grade level.
     * 
     * @return The grade level of the athlete.
     */
    
    

    /**
     * Gets the sport the athlete participates in.
     * 
     * @return The sport of the athlete.
     */
   


    /**
     * Gets the athlete's position in the sport.
     * 
     * @return The position of the athlete.
     */
    


    /**
     * Gets the height of the athlete.
     * 
     * @return The height in inches.
     */
   


    /**
     * Gets the weight of the athlete.
     * 
     * @return The weight in pounds.
     */
    


    // Mutator (setter) methods

    /**
     * Sets the athlete's name.
     * 
     * @param name The new name of the athlete.
     */
    


    /**
     * Sets the athlete's grade level.
     * 
     * @param grade The new grade level.
     */
    


    /**
     * Sets the sport the athlete participates in.
     * 
     * @param sport The new sport.
     */
    


    /**
     * Sets the athlete's position.
     * 
     * @param position The new position.
     */
    


    /**
     * Sets the height of the athlete.
     * 
     * @param height The new height in inches.
     */
    


    /**
     * Sets the weight of the athlete.
     * 
     * @param weight The new weight in pounds.
     */
    


    /**
     * Returns a string representation of the athlete.
     * 
     * @return A string containing all attributes of the athlete.
     */
    @Override
    public String toString() {


    }

    /**
     * The main method tests the Athlete class by creating instances and using 
     * its methods.
     * 
     * @param args Command-line arguments (not used).
     */
    public static void main(String[] args) {
        // Creating athlete objects
        

        // Displaying initial details
        

        // Modifying attributes using setters
        

        // Displaying updated details
        

    }
}

```

## HighSchoolStudent.java

```java
/**
 * The HighSchoolStudent class represents a high school student with a name.
 * It includes a static counter to track the number of students created.
 */
public class HighSchoolStudent {
    // instance variable
    

    // static instance variable
    

    /**
     * Constructs a new HighSchoolStudent with the given name.
     * Increments the student counter upon creation.
     *
     * @param name The name of the student.
     */
    
    
    /**
     * Returns the total number of students created.
     *
     * @return the total number of students created.
     */
    

    /**
     * Returns a string representation of the student.
     *
     * @return A string containing the student's name.
     */
    public String toString() {
        return "Student Name: " + name;
    }
}
```

## SchoolMember.java

```java
/**
 * The SchoolMember class represents a student in a school with a name and grade level.
 */
public class SchoolMember {
    /** The name of the student. */
    private String name;

    /** The grade level of the student (9, 10, 11, or 12). */
    private int gradeLevel;

    /** A static counter to track the total number of students. */
    public static int memberCounter = 0;

    // TODO: Declare additional static variables to track students in each grade level.

    /**
     * Constructs a SchoolMember object with a name and grade level.
     * Increments the total member counter and the respective grade counter.
     *
     * @param name The name of the student.
     * @param gradeLevel The grade level of the student (9-12).
     */
    public SchoolMember(String name, int gradeLevel) {
        this.name = name;
        this.gradeLevel = gradeLevel;
        memberCounter++;
        // TODO: Update the appropriate grade level counter.
    }

    /**
     * Returns the grade level of the student.
     *
     * @return The grade level of the student.
     */
    public int getGradeLevel() {
        // TODO: Implement this method
        return 0; // Placeholder
    }

    /**
     * Prints the total number of school members and breakdown by grade.
     */
    public static void printMemberCounter() {
        System.out.println("Total members: " + memberCounter);
        // TODO: Print the number of students in each grade level.
    }

    /**
     * Returns a string representation of the student.
     *
     * @return A string containing the student's name and grade level.
     */
    public String toString() {
        return "Student Name: " + name + ", Grade Level: " + gradeLevel;
    }

    /**
     * The main method for testing.
     *
     * @param args Command-line arguments (not used).
     */
    public static void main(String[] args) {
        // TODO: Create at least 3 students with different grade levels
        // TODO: Call printMemberCounter() to display the counts
        
    }
}

```

## Scoreboard.java

```java
/**
 * The Scoreboard class keeps track of scores in a two-team game where teams alternate turns.
 * During a turn, a team makes one or more plays. Each play can score points and the team's
 * turn continues, or the play can fail (score 0 points) and the team's turn ends.
 */
public class Scoreboard {
    // TODO: Instance variables



    /**
     * Constructs a new Scoreboard object for tracking scores between two teams.
     * The game always begins with team 1 as the active team.
     *
     * @param team1 the name of team 1
     * @param team2 the name of team 2
     */
     // TODO: Implement Constructor


    /**
     * Records a play in the game. If points are scored (parameter > 0), the active team's
     * score is updated and that team remains active. If the play fails (parameter = 0),
     * the active team's turn ends and the inactive team becomes active.
     *
     * @param points the number of points scored on this play (0 if the play failed)
     * Precondition: points ≥ 0
     */
     // Implement this method


    /**
     * Returns a string containing the current state of the game in the format:
     * "team1Score-team2Score-activeTeamName"
     * For example: "0-0-Red" or "1-3-Blue"
     *
     * @return a string representing the current game state
     */
     // TODO: Implemenent this method



}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.computersciencea.com/group/session-14.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
