Modify class Gradebook (and GradeBookText) as follows:

Use your modified class in a test application that demonstrates the class’s new capabilities.

Your test class should look something like this:

public static void main( String args[] )
{
// create the GradeBook1 objects
GradeBook1 gradeBook1 = new GradeBook1(
"ITEC 1978-01N Intro to Java Programming",
"Bill Krieger" );
GradeBook1 gradeBook2 = new GradeBook1(
"ITEC 1986-01N - Intermediate Java Programming",
"Paul Parker" );

// display initial value of courseName for each GradeBook1
System.out.printf( "gradeBook1 course name is: %s\n",
gradeBook1.getCourseName() );
System.out.printf( "gradeBook2 course name is: %s\n",
gradeBook2.getCourseName() );

// display initial value of instructor for each GradeBook1
System.out.printf( "gradeBook1 instructor is: %s\n",
gradeBook1.getInstructor() );
System.out.printf( "gradeBook2 instructor is: %s\n",
gradeBook2.getInstructor() );

// display initial value of everything for each GradeBook1
gradeBook1.displayMessage();
gradeBook2.displayMessage();
} // end main

Your modified ‘GradeBook‘ class should look something like this:

// Exercise 3.11: GradeBook1.java
// GradeBook class with a constructor to initialize the course name.

{
//*****************************
// 1. These are the instance variable(s):
// You gotta add a new one.
//*****************************
private String courseName;

//*****************************
// 3. This is the constructor.
// It needs to be modified
//*****************************
public GradeBook1( String name, String instructor )
{
courseName = name; // initializes courseName
}

//*****************************
// 2. These are the setters and getters.
// You gotta add a new one of each.
//*****************************
public void setCourseName( String name )
{
courseName = name;
}
public String getCourseName()

{
return courseName;
}

//*****************************
// 2. This is the displayMessage method.
// It needs to be modified.
public void displayMessage()
{
System.out.printf( "Welcome to the grade book for\n%s!\n",
getCourseName() );
}

} // end class GradeBook1

By following the comments in the above code, you should be able to get the modified ‘GradeBook’ class to work. The solution will be available here and here the end of next week’s class.