Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

GradeBook class modifications Modify classes GradeBook and GradeBookTest ( Fig 7

ID: 3557160 • Letter: G

Question

GradeBook class modifications

Modify classes GradeBook and GradeBookTest ( Fig 7.10 ) as follows:

Include a second String instance variable (field) that represents the name of the instructor for the course.

Provide a set method to change the instructor's name and a get method to retrieve it.

Modify the constructor to specify two parameters - one for the course name and one for the course instructor.

Modify method displayMessage such that it first outputs the welcome message and course name, then outputs "This course is presented by: " followed by the instructor's name.

---------------------------------------------------------------------------------------------------------------------------------------------------

Here is a link to the source code for GradeBook.java and GradeBookTest.java :

-----> http://web.cerritos.edu/jwilson/SitePages/cis_182/assignments/Figure_7-10.zip

Explanation / Answer

// Fig. 7.10: GradeBook.java

// GradeBook class with a constructor to initialize the course name.

public class GradeBook

{

private String courseName; // course name for this GradeBook

private String instructorName;

// constructor initializes courseName with String argument and instrutor name

public GradeBook(String courseName, String instructorName) {

super();

this.courseName = courseName;

this.instructorName = instructorName;

}

// method to get the instructorName

public String getInstructorName() {

return instructorName;

}

// method to set the instructorName

public void setInstructorName(String instructorName) {

this.instructorName = instructorName;

}

// constructor initializes courseName with String argument

public GradeBook( String name )

{

courseName = name; // initializes courseName

} // end constructor

// method to set the course name

public void setCourseName( String name )

{

courseName = name; // store the course name

} // end method setCourseName

// method to retrieve the course name

public String getCourseName()

{

return courseName;

} // end method getCourseName

// display a welcome message to the GradeBook user

public void displayMessage()

{

// this statement calls getCourseName to get the

// name of the course this GradeBook represents

System.out.printf( "Welcome to the grade book for %s! ",

getCourseName() );

System.out.println("This course is presented by:"+getInstructorName());

} // end method displayMessage

} // end class GradeBook

?

/**************************************************************************

* (C) Copyright 1992-2010 by Deitel & Associates, Inc. and *

* Pearson Education, Inc. All Rights Reserved. *

* *

* DISCLAIMER: The authors and publisher of this book have used their *

* best efforts in preparing the book. These efforts include the *

* development, research, and testing of the theories and programs *

* to determine their effectiveness. The authors and publisher make *

* no warranty of any kind, expressed or implied, with regard to these *

* programs or to the documentation contained in these books. The authors *

* and publisher shall not be liable in any event for incidental or *

* consequential damages in connection with, or arising out of, the *

* furnishing, performance, or use of these programs. *

*************************************************************************/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote