Home / Questions / Problem: Develop a class encapsulating the concept of a college course, assuming that a co...

Problem: Develop a class encapsulating the concept of a college course, assuming that a course has f

Problem: Develop a class encapsulating the concept of a college course, assuming that a course has following
attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a
constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the
behavior of the class and its methods.


The outline of the class is given as follows:


public class Course {
private String course;
private String description;
private int credits;
private int maxStudents;
public Course( ) { }
public Course (String course, String desc, int credits, int maxNum ) { }
public String getCourse ( ) { }
public void setCourse ( String c ) { }
public String getDescription ( ) { }
public void setDescription ( String desc ) { }
public int getCredits ( ) { }
public void setCredits ( int cred ) { }
public int getStudents ( ) { }
public void setStudents ( int students ) { }
public String toString ( ) { }
public boolean equals ( Object obj ) { }
public void finalize ( ) { }
}


ALL METHODS MUST BE IMPLEMENTED!!!
Write a client program(test class) to THOROUGHLY test the class Course. In the client program, create two Course
objects. Assign any values to the two objects. Exercise the methods to verify their functionality

Approach to Testing:
• Create TWO class objects
o One object with the default constructor
 Test the set methods initializing the instance variables to the desired values.
 Use the get methods to verify that the ‘set’s worked properly.
o One object with the overloaded constructor – setting unique values in instance variables
• Test the ‘set’ methods with the default object
• Test the ‘get’ methods – System.out.println ( “course = “ + obj.getCourse() ).
• Test the ‘toString’ method – never EXPLICITLY call the ‘toString’ method.
Two separate files:
• Course.java
• CourseTest.java (client program) ( or other name )
Approach to Testing:
•Create an object with the default constructor
o Verify and print to insure default values were assigned.
 Use the ‘get’ methods coupled with output
statements.
o Initialize all of the instance variables using the ‘set’
methods.
o Verify and print the values of the instance variables using
the ‘toString’ method.
•Create an object with the overloaded constructor.
o Verify and print the values of the instance variables using
the ‘toString’ method.
•Verify each of the other methods –
o Equals method – needs three objects, 2 equal, 2 unequal
 Compare equals
 Compare unequal’s
o ‘toString’ method
o Finalize method.
o Others.

Apr 07 2020 Read more Less More

Answer (Solved)

question Subscribe To Get Solution

Recent Questions

Chat Now

Welcome to Live Chat

Welcome to MyCourseHelp Services, World's leading Academic solutions provider with Millions of Happy Students.

Please fill in the form