At first,
You are expanding the Students class in the course class, which means that the student class receives all the properties of the coruse class. Thus, the student class does not have the courseTitle property.
Secondly, yes, this is optional - you need to do the following:
public class Course { private Award courseAward; private String courseCode; public String courseTitle; private String courseLeader; private int courseDuration; private boolean courseSandwich; public Course(String code, String title, Award award, String leader, int duration, boolean sandwich) { courseCode = code; courseTitle = title; courseAward = award; courseLeader = leader; courseDuration = duration; courseSandwich = sandwich; } } public class Student { private int studentNumber; private String studentName; private int studentPhone;
A usage example would be something like this:
Course course = new Course("ASD", "TITLE", null, "ME", 50, true); Student student = new Student(1, "JOHN", "5551234", course);
And then, get the course information you need from the student, for example:
student.studentCourse.courseTitle;
Since now student.studentCourse will be an object of the course with all its properties.
Greetings
source share