I'm currently learning MVC for java and I saw this simple
tutorial.
What confuses me most is the use of classes
This is for the model:
package MyPackage;
public class Course {
private String CourseName;
private String CourseId;
private String CourseCategory;
public String getId() {
return CourseId;
}
This is for the VIEW:
package MyPackage;
public class CourseView {
public void printCourseDetails(String CourseName, String CourseId, String CourseCategory){
System.out.println("Course Details: ");
System.out.println("Name: " + CourseName);
System.out.println("Course ID: " + CourseId);
System.out.println("Course Category: " + CourseCategory);
}
}
This is for the Controller:
package MyPackage;
public class CourseController {
private Course model;
private CourseView view;
public CourseController(Course model, CourseView view){
this.model = model;
this.view = view;
}
In the controller class where the code is written like this
private Course model;
private CourseView view;
is where I'm confused. The
Course
and
CourseView
was a
Class
but treated like a data type? I really don't get it. I got frustrated by this.
What I have tried:
I'm trying to find a good tutorial on what happened there but I don't know what to search for. I tried searching how to use classes in java.
NOTE:
I didn't copy the whole code from the website because my thread will become long. I just copied what I think is needed to make my question clear.