I have never completed a C or VB or C++ programming course.
So I am reading a C++ tutorial, which shows me this introducing a constructor:
The constructor assigns the message Course Not Changed to the instance variable status. This is the default status for each instance of the class. The value of the status instance variable is changed from the default value to the message Course Dropped by the dropCourse method.
class MyJavaApplication {
public static void main (String args[]) {
RegistrationForm regForm = new RegistrationForm();
regForm.dropCourse(CS102,1234);
System.out.println("Status: " + regForm.status);
}
}
class RegistrationForm {
String status;
void RegistrationForm () {
status = "Course Not Changed.";
}
void dropCourse(int courseNumber, int studentNumber)
{status = "Course: "+ courseNumber + " is dropped for
student: " + studentNumber;
}
}
I am thinking the constructor is this line:
void RegistrationForm () {
status = "Course Not Changed.";
}
Am I correct?