0% found this document useful (0 votes)
22 views3 pages

Code

The document defines a set of classes representing a university system, including Course, Department, Professor, and Student. It demonstrates the relationships between these entities by creating instances and linking them, such as assigning a professor to a department and students to courses. The main method outputs information about a student's first course, including the course name, professor's name, and department name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Code

The document defines a set of classes representing a university system, including Course, Department, Professor, and Student. It demonstrates the relationships between these entities by creating instances and linking them, such as assigning a professor to a department and students to courses. The main method outputs information about a student's first course, including the course name, professor's name, and department name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import java.util.

*;

class Course {

String code;

String name;

Department department;

Professor teacher;

Student[] students;

String[] days;

Date time;

class Department {

String name;

Professor head;

Course[] courses;

Student[] students;

class Professor {

String no;

String name;

String dob;

String rank;

Department department;

Student[] advisee;

Course[] coursesGiven;

class Student {

String no;

String name;

String dob;

Department department;

Professor advisor;
Course[] coursesTaken;

public class Test {

public static void main(String[] args) {

Department department1 = new Department();

department1.name = "Software Engineering";

Professor professor1 = new Professor();

professor1.name = "Ahmet Arslan";

Course course1 = new Course();

course1.name = "Int. to Software Engineering";

Student student1 = new Student();

student1.name = "Akin Kaldiroglu";

// Head of Software Engineering department is Ahmet Arslan and consequently his department
is Software Engineering.

department1.head = professor1;

professor1.department = department1;

// Department of Int. to Software Engineering course is Software Engineering and consequently


the course

// Int. to Software Engineering belongs to Software Engineering department.

course1.department = department1;

department1.courses = new Course[100];

department1.courses[0] = course1;

course1.teacher = professor1;

professor1.coursesGiven = new Course[5];

professor1.coursesGiven[0] = course1;
professor1.advisee = new Student[10];

professor1.advisee[0] = student1;

student1.advisor = professor1;

student1.coursesTaken = new Course[7];

student1.coursesTaken[0] = course1;

course1.students = new Student[100];

course1.students[0] = student1;

System.out.println("Name of student student1's first course is " +


student1.coursesTaken[0].name);

System.out.println("Name of student student1's first course's professor is " +


student1.coursesTaken[0].teacher.name);

System.out.println("Name of student student1's first course's professor's department is " +


student1.coursesTaken[0].teacher.department.name);

System.out.println("******************");

You might also like