public class GradeBook
1: // Fig. 3.7: GradeBook.java
2: // GradeBook class that contains a courseName instance variable
3: // and methods to set and get its value.
4:
5: public class GradeBook
6: {
7: private String courseName; // course name for this GradeBook
8:
9: // method to set the course name
10: public void setCourseName( String name )
11: {
12: courseName = name; // store the course name
13: } // end method setCourseName
14:
15: // method to retrieve the course name
16: public String getCourseName()
17: {
18: return courseName;
19: } // end method getCourseName
20:
21: // display a welcome message to the GradeBook user
22: public void displayMessage()
23: {
24: // this statement calls getCourseName to get the
25: // name of the course this GradeBook represents
26: System.out.printf( "Welcome to the grade book for\n%s!\n",
27: getCourseName() );
28: } // end method displayMessage
29:
30: } // end class GradeBook
31:
32:
33: /**************************************************************************
34: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
35: * Pearson Education, Inc. All Rights Reserved. *
36: * *
37: * DISCLAIMER: The authors and publisher of this book have used their *
38: * best efforts in preparing the book. These efforts include the *
39: * development, research, and testing of the theories and programs *
40: * to determine their effectiveness. The authors and publisher make *
41: * no warranty of any kind, expressed or implied, with regard to these *
42: * programs or to the documentation contained in these books. The authors *
43: * and publisher shall not be liable in any event for incidental or *
44: * consequential damages in connection with, or arising out of, the *
45: * furnishing, performance, or use of these programs. *
46: *************************************************************************/