For each of these problems, you should create the class or classes and test them
ID: 3538410 • Letter: F
Question
For each of these problems, you should create the class or classes and test them with a test harness class. The test harness class is where the main should be. The test harness should create instances of your class(es) and demonstrate that each operation works as it should.
It is typical to name the name test harness something of the form T_<Class or system name>. For example,
In addition to creating a correct solution, you should be also using good coding practices: appropriate use of programming constructs, conformance to coding standards, and good commenting.
These problems are optional and will not be formally reviewed. If you have questions or would like some feedback on your solution, do not hesitate to ask.
Update the Gradebook system so that you can create instances of MutlipleChoice, Essay, and TeamProject, and add instances of each to the Gradebook for a given student. Further, you can get a weighted average for a given student. That is, evolve the Gradebook classes appropriately so that the following operations, which will be part of Gradebook, work correctly:
There are several things to consider:
Explanation / Answer
public class GradeBook
{
private String courseName; // course name for this GradeBook
/* WRITE CODE TO DECLARE A SECOND STRING INSTANCE VARIABLE*/
// constructor initializes courseName with String supplied as 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
/*WRITE CODE TO DECLARE A GET AND A SET METHOD FOR THE INSTRUCTOR'S NAME*/
// 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() );
/*WRITE CODE TO OUTPUT THE INSTRUCTOR'S NAME*/
} // end method displayMessage
} // end class GradeBook
HERE IS THE SECOND PAGE
public class GradeBookTest
{
// main method begins program execution
public static void main( String args[] )
{
// create GradeBook object
GradeBook gradeBook1 = new GradeBook(
"CS101 Introduction to Java Programming" );
// display initial value of courseName for each GradeBook
System.out.printf( "gradeBook1 course name is: %s ",
gradeBook1.getCourseName() );
/*WRITE CODE TO CHANGE INSTRUCTOR'S NAME AND OUTPUT CHANGES */
} // end main
} // end class GradeBookTest
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.