witchway915

Untitled

Sep 5th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // Fig. 3.10: GradeBook.java
  2. // GradeBook class with a constructor to initialize the course name.
  3.  
  4. public class GradeBook
  5. {
  6. private String courseName; // course name for this GradeBook
  7.  
  8. // constructor initializes courseName with String argument
  9. public GradeBook( String name )
  10. {
  11. courseName = name; // initializes courseName
  12. } // end constructor
  13.  
  14. // method to set the course name
  15. public void setCourseName( String name )
  16. {
  17. courseName = name; // store the course name
  18. } // end method setCourseName
  19.  
  20. // method to retrieve the course name
  21. public String getCourseName()
  22. {
  23. return courseName;
  24. } // end method getCourseName
  25.  
  26. // display a welcome message to the GradeBook user
  27. public void displayMessage()
  28. {
  29. // this statement calls getCourseName to get the
  30. // name of the course this GradeBook represents
  31. System.out.printf( "Welcome to the grade book for\n%s!\n",
  32. getCourseName() );
  33. } // end method displayMessage
  34. } // end class GradeBook
Advertisement
Add Comment
Please, Sign In to add comment