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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education