Java Reference
In-Depth Information
The method
setCourseInfo
sets the values of the instance variables according to
the values of the parameters. Its definition is:
public void
setCourseInfo(String cName, String cNo,
int
credits)
{
courseName = cName;
courseNo = cNo;
courseCredits = credits;
}
The definitions of the methods
setCourseName
,
setCourseNumber
,and
setCourseCredits
are similar to the method
setCourseInfo
. Their definitions are:
public void
setCourseName(String cName)
{
courseName = cName;
}
public void
setCourseNumber(String cNo)
{
courseNo = cNo;
}
public void
setCourseCredits(
int
credits)
{
courseCredits = credits;
}
The method
toString
returns the course information as a string. Its definition is:
public
String toString()
{
return
String.format("%-12s%-15s%4s", courseNo,
courseName, courseCredits);
}
//end toString
The definitions of the remaining methods and constructors are as follows:
public
Course(String cName, String cNo,
int
credits)
{
courseName = cName;
courseNo = cNo;
courseCredits = credits;
}
public
Course()
{
courseName = "";
courseNo = "";
courseCredits = 0;
}
Search WWH ::
Custom Search