Source of GradeBookTest.java


  1: // Fig. 3.8: GradeBookTest.java
  2: // Create and manipulate a GradeBook object.
  3: import java.util.Scanner; // program uses Scanner
  4: 
  5: public class GradeBookTest
  6: {
  7:    // main method begins program execution
  8:    public static void main( String args[] )
  9:    { 
 10:       // create Scanner to obtain input from command window
 11:       Scanner input = new Scanner( System.in );
 12: 
 13:       // create a GradeBook object and assign it to myGradeBook
 14:       GradeBook myGradeBook = new GradeBook(); 
 15: 
 16:       // display initial value of courseName
 17:       System.out.printf( "Initial course name is: %s\n\n",
 18:          myGradeBook.getCourseName() );
 19: 
 20:       // prompt for and read course name
 21:       System.out.println( "Please enter the course name:" );
 22:       String theName = input.nextLine(); // read a line of text
 23:       myGradeBook.setCourseName( theName ); // set the course name
 24:       System.out.println(); // outputs a blank line
 25: 
 26:       // display welcome message after specifying course name
 27:       myGradeBook.displayMessage();
 28:    } // end main
 29: 
 30: } // end class GradeBookTest
 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:  *************************************************************************/