// GradeBook.java - solution to CS 5JA assignment 2, part 3, Winter 2009 // updated by cmc, 1/12/09 public class GradeBook { private String courseName; private String instructor; // a) INSTANCE VARIABLE FOR INSTRUCTOR NAME // c) CONSTRUCTOR HANDLES TWO NAMES: COURSE AND INSTRUCTOR public GradeBook( String cName, String iName ) { courseName = cName; instructor = iName; } // method to set the course name public void setCourseName( String name ) { courseName = name; } // method to retrieve the course name public String getCourseName() { return courseName; } // b.1) METHOD TO SET INSTRUCTOR NAME public void setInstructorName( String name) { instructor = name; } // b.2) METHOD TO GET INSTRUCTOR NAME public String getInstructorName() { return instructor; } // d) MESSAGE DISPLAY METHOD MODIFIED public void displayMessage() { System.out.printf( "Welcome to the grade book for\n%s!\n", getCourseName() ); System.out.printf( "This course is presented by: %s%n", getInstructorName() ); } } /* Note: original file is Fig. 3.10 of Deitel text. Just comment changes are made to the copy posted for this assignment. */