-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollegeManagementSystem.java
More file actions
240 lines (210 loc) · 9.54 KB
/
Copy pathCollegeManagementSystem.java
File metadata and controls
240 lines (210 loc) · 9.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import java.util.ArrayList;
import java.util.List;
// Class to represent a Student
class Student {
private String firstName;
private String lastName;
private String sex;
private int age;
private String dateOfBirth;
private String cnp; // CNP - Personal Numeric Code
private String address;
public Student(String firstName, String lastName, String sex, int age, String dateOfBirth, String cnp, String address) {
this.firstName = firstName;
this.lastName = lastName;
this.sex = sex;
this.age = age;
this.dateOfBirth = dateOfBirth;
this.cnp = cnp;
this.address = address;
}
// Method to display student details
public void displayStudentDetails() {
System.out.println("Student: " + firstName + " " + lastName + ", Sex: " + sex + ", Age: " + age +
", DOB: " + dateOfBirth + ", CNP: " + cnp + ", Address: " + address);
}
}
// Class to represent a Professor
class Professor {
public String firstName;
public String lastName;
private String sex;
private int age;
private String dateOfBirth;
private String cnp;
private String address;
public Professor(String firstName, String lastName, String sex, int age, String dateOfBirth, String cnp, String address) {
this.firstName = firstName;
this.lastName = lastName;
this.sex = sex;
this.age = age;
this.dateOfBirth = dateOfBirth;
this.cnp = cnp;
this.address = address;
}
// Method to display professor details
public void displayProfessorDetails() {
System.out.println("Professor: " + firstName + " " + lastName + ", Sex: " + sex + ", Age: " + age +
", DOB: " + dateOfBirth + ", CNP: " + cnp + ", Address: " + address);
}
}
// Class to represent a Course
class Course {
public String name;
private String schedule;
private String duration;
private String description;
private Professor assignedProfessor;
public Course(String name, String schedule, String duration, String description) {
this.name = name;
this.schedule = schedule;
this.duration = duration;
this.description = description;
}
// Method to assign a professor to this course
public void assignProfessor(Professor professor) {
this.assignedProfessor = professor;
}
// Method to display course details along with assigned professor
public void displayCourseDetails() {
System.out.println("Course: " + name + ", Schedule: " + schedule + ", Duration: " + duration +
", Description: " + description);
if (assignedProfessor != null) {
System.out.print("Assigned Professor: ");
assignedProfessor.displayProfessorDetails();
} else {
System.out.println("Assigned Professor: None");
}
}
}
// Class to represent the College
class College {
private List<Student> students;
private List<Professor> professors;
private List<Course> courses;
public College() {
this.students = new ArrayList<>();
this.professors = new ArrayList<>();
this.courses = new ArrayList<>();
}
// Add a new student
public void addStudent(Student student) {
students.add(student);
}
// Add a new professor
public void addProfessor(Professor professor) {
professors.add(professor);
}
// Add a new course
public void addCourse(Course course) {
courses.add(course);
}
// Assign a professor to a course
public void assignProfessorToCourse(String courseName, Professor professor) {
for (Course course : courses) {
if (courseName.equalsIgnoreCase(course.name)) {
course.assignProfessor(professor);
System.out.println("Assigned " + professor.firstName + " " + professor.lastName + " to " + courseName);
return;
}
}
System.out.println("Course not found.");
}
// Display details of all courses
public void viewCourses() {
for (Course course : courses) {
course.displayCourseDetails();
}
}
// Display details of all students
public void viewStudents() {
for (Student student : students) {
student.displayStudentDetails();
}
}
// Display details of all professors
public void viewProfessors() {
for (Professor professor : professors) {
professor.displayProfessorDetails();
}
}
}
// Main class to run the program
public class CollegeManagementSystem {
public static void main(String[] args) {
// Create an instance of College
College college = new College();
// Create some students
Student student1 = new Student("Sorin", "Nastase", "Male", 25, "1999-01-01", "1010199702468", "4 Aurara St.");
Student student2 = new Student("Aura", "Pascale", "Female", 27, "1997-02-02", "2020297796413", "25 Portitei St.");
Student student3 = new Student("Aurel", "Pascale", "Male", 25, "1999-03-03", "1030399874685", "35 Eternitati St.");
Student student4 = new Student("Veronica", "Micle", "Female", 27, "1997-04-04", "2040497873216", "45 Garoafei St.");
Student student5 = new Student("Florian", "Tanase", "Male", 25, "1999-05-05", "2050599678234", "25 Minciuni St.");
Student student6 = new Student("Florica", "Tanase", "Female", 28, "1996-06-06", "1060696874321", "28 Libera St.");
Student student7 = new Student("Bogdan", "Mocanu", "Male", 26, "1998-07-07", "1070798873541", "57 Ocupata St.");
Student student8 = new Student("Mihaela", "Padureanu", "Female", 24, "1998-08-08", "2080898762432", "35 Sovata St.");
// Add students to the college
college.addStudent(student1);
college.addStudent(student2);
college.addStudent(student3);
college.addStudent(student4);
college.addStudent(student5);
college.addStudent(student6);
college.addStudent(student7);
college.addStudent(student8);
// Create some professors
Professor professor1 = new Professor("Bogdan", "Petrescu", "Male", 45, "1979-03-03", "3567924678642", " 25 Moldoveanu S. St.");
Professor professor2 = new Professor("Andreea", "Lipovenescu", "Female", 40, "1983-04-04", "2468721647832", "26 Garoafei St.");
Professor professor3 = new Professor("Martina", "Agache", "Female", 50, "1973-05-05", "1356789432545", "29 Eternitati St.");
Professor professor4 = new Professor("Bogdan", "Pascale", "Male", 55, "1968-06-06", "1246783216579", "38 Aurora St.");
Professor professor5 = new Professor("Nicolae", "Ion", "Male", 52, "1971-07-07", "2346789412562", "60 Dobrogeanu Ghe. St.");
Professor professor6 = new Professor("Petrica", "Pascale", "Male", 48, "1976-08-08", "1327856743259", "54 Pascale I. St.");
Professor professor7 = new Professor("David", "Florian", "Male", 60, "1963-09-09", "1325796435824", "23 Apelor St.");
Professor professor8 = new Professor("Ancuta", "Moldoveanu", "Female", 43, "1980-10-10", "23465876354126", "3 Eterna St.");
// Add professors to the college
college.addProfessor(professor1);
college.addProfessor(professor2);
college.addProfessor(professor3);
college.addProfessor(professor4);
college.addProfessor(professor5);
college.addProfessor(professor6);
college.addProfessor(professor7);
college.addProfessor(professor8);
// Create some courses
Course course1 = new Course("Math", "Mon/Wed/Fri 9-10am", "3 months", "Advanced Calculus");
Course course2 = new Course("Computer Science", "Tue/Thu 2-4pm", "4 months", "Intro to Programming");
Course course3 = new Course("Physics", "Mon/Wed/Fri 10-11am", "3 months", "Mechanics and Waves");
Course course4 = new Course("Chemistry", "Tue/Thu 9-11am", "4 months", "Organic Chemistry");
Course course5 = new Course("Biology", "Mon/Wed 1-2pm", "3 months", "Genetics and Evolution");
Course course6 = new Course("Geography", "Tue/Thu 10-11:30am", "4 months", "Physical Geography");
Course course7 = new Course("English", "Mon/Wed/Fri 11am-12pm", "3 months", "Shakespearean Literature");
Course course8 = new Course("History", "Tue/Thu 1-3pm", "4 months", "World History");
// Add courses to the college
college.addCourse(course1);
college.addCourse(course2);
college.addCourse(course3);
college.addCourse(course4);
college.addCourse(course5);
college.addCourse(course6);
college.addCourse(course7);
college.addCourse(course8);
// Assign professors to courses
college.assignProfessorToCourse("Math", professor1);
college.assignProfessorToCourse("Computer Science", professor2);
college.assignProfessorToCourse("Physics", professor3);
college.assignProfessorToCourse("Chemistry", professor4);
college.assignProfessorToCourse("Biology", professor5);
college.assignProfessorToCourse("Geography", professor6);
college.assignProfessorToCourse("English", professor7);
college.assignProfessorToCourse("History", professor8);
// Display all courses
System.out.println("\n--- Courses Offered ---");
college.viewCourses();
// Display all students
System.out.println("\n--- Student List ---");
college.viewStudents();
// Display all professors
System.out.println("\n--- Professor List ---");
college.viewProfessors();
}
}