Student / StudentDriver – Building Objects

Date: November 12

This document shows the spec sheet, pseudocode, and Java source code for the Student class and the StudentDriver class. The driver class creates (instantiates) a Student object and calls its methods. All methods in the Student class have a void return type.


Spec Sheet – Student Class

File Name: Student.java
Class Name: Student
Type: Blueprint class (will be used to create Student objects)

1. Purpose

The Student class models a high school student with a name, grade level, and GPA. It provides methods to change the student’s data and display it. All methods have a void return type.

2. Instance Variables (Fields)

Name Type Description
name String Student’s name
gradeLevel int Student’s current grade level (9–12)
gpa double Student’s GPA (0.0–4.0)

3. Methods (All void)

Method 1 – setName(String n)

Method 2 – setGradeLevel(int grade)

Method 3 – setGpa(double g)

Method 4 – printStudentInfo()

Method 5 – promote()

Method 6 – resetStudent()


Pseudocode – Student Class

CLASS Student

    // Fields
    DECLARE name AS String
    DECLARE gradeLevel AS int
    DECLARE gpa AS double

    METHOD setName(n AS String)
        SET name TO n
    END METHOD

    METHOD setGradeLevel(grade AS int)
        SET gradeLevel TO grade
    END METHOD

    METHOD setGpa(g AS double)
        SET gpa TO g
    END METHOD

    METHOD printStudentInfo()
        DISPLAY "Student Name: " + name
        DISPLAY "Grade Level: " + gradeLevel
        DISPLAY "GPA: " + gpa
    END METHOD

    METHOD promote()
        INCREASE gradeLevel BY 1
        DISPLAY name + " has been promoted to grade " + gradeLevel
    END METHOD

    METHOD resetStudent()
        SET name TO empty string
        SET gradeLevel TO 0
        SET gpa TO 0.0
        DISPLAY "Student record reset."
    END METHOD

END CLASS
    

Spec Sheet – StudentDriver Class

File Name: StudentDriver.java
Class Name: StudentDriver
Type: Driver / test class (has main method)

1. Purpose

The StudentDriver class tests the Student class. It creates (instantiates) one Student object and calls the methods to demonstrate instantiation and method calls.

2. Methods

public static void main(String[] args)


Pseudocode – StudentDriver Class

CLASS StudentDriver

    METHOD main(args)

        // 1. Create (instantiate) a Student object
        DECLARE s1 AS Student
        SET s1 TO NEW Student object

        // 2. Set the student's data
        CALL s1.setName("Aiden")
        CALL s1.setGradeLevel(11)
        CALL s1.setGpa(3.75)

        // 3. Print student information
        CALL s1.printStudentInfo()

        // 4. Promote the student
        CALL s1.promote()

        // 5. Reset the student record
        CALL s1.resetStudent()

    END METHOD

END CLASS
    

In your java program YOUR OJECT NAME MUST BE YOUR FIRST NAME.

Submission Requirements

Submit the following to you google drive under your class name and Google Classroom:

Ensure the final output is clearly visible in the Eclipse console in both the screenshot and the video.