Problem: Develop a class encapsulating the concept of a college course, assuming that a course has followingattributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include aconstructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test thebehavior 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 Courseobjects. Assign any values to the two objects. Exercise the methods to verify their functionality Approach to Testing:• Create TWO class objectso 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 constructoro Verify and print to insure default values were assigned. Use the ‘get’ methods coupled with outputstatements.o Initialize all of the instance variables using the ‘set’methods.o Verify and print the values of the instance variables usingthe ‘toString’ method.•Create an object with the overloaded constructor.o Verify and print the values of the instance variables usingthe ‘toString’ method.•Verify each of the other methods –o Equals method – needs three objects, 2 equal, 2 unequal Compare equals Compare unequal’so ‘toString’ methodo Finalize method.o Others.
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
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.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images