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 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
complete, an income statement, statement of owner’s equity, and balance sheet using the information provided below for Rya’s Planning ServicesCash $21,500Accounts Receiva...
Mar 21 2020A Dutch Auction is used to sell securities. What is 1 pro and 1 con of a Dutch Auction? Type your answers in the blue text box below.
Aug 17 2020The ledger of Sagovic Rental Agency on March 31 of the current year includes the selected accounts on page 206 before adjusting entries have been prepared.
May 03 2020Brian is starting a new business, his own bakery, and would like your advice. He recently finished an apprenticeship with a large bakery chain that specialised in bread p...
May 29 2018the machine will be depreciated using the MACRS schedule. at the end of year 2 the machine is sold for $85000. what is the after tax cash flow from the sale of the machin...
Aug 13 2020What are some of the benefits of enterprise application integration (EAI)?84) Standards such as http, https, html5, css3, JavaScript, and Web services enable programs on ...
Dec 24 2019Phillips Inc. produces two distinct products, A and B. The products do not compete with each other in the marketplace; that is, neither cost, price, nor demand for one pr...
May 06 2020Draft financial information for Darfield Electronics for the year to 30 June 2021 is as follows.
Feb 12 2020its a finance needs to be done ASAPTriad common stock is selling for $27.80 a share and the required rate of return is 2.81%. What is the dividend amount? $.31 $ 78 $ 3.4...
Dec 04 2019al "Cool" Cooper has $200 to spend on cell phones and sunglasses. a. Each cell phone costs $100 and each pair of sunglasses costs $50. Which bundles lie on Cal s budget l...
May 02 2020Welcome to MyCourseHelp Services, World's leading Academic solutions provider with Millions of Happy Students.