|
|
@ -1,6 +1,9 @@ |
|
|
|
package org.example; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class Administration { |
|
|
|
/** |
|
|
@ -405,38 +408,6 @@ public class Administration { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void createCourse(String courseName, String courseID, int credits) { |
|
|
|
// Check if a course with the given ID already exists |
|
|
|
if (findCourseByID(courseID) != null) { |
|
|
|
System.out.println("A course with ID " + courseID + " already exists."); |
|
|
|
} else { |
|
|
|
Course newCourse = new Course(courseName, courseID, credits); |
|
|
|
courses.add(newCourse); |
|
|
|
System.out.println("Course " + courseName + " (" + courseID + ") created successfully."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public boolean enrollStudentInCourse(String studentId, String courseId) { |
|
|
|
Student student = findStudentById(studentId); |
|
|
|
Course course = findCourseByID(courseId); |
|
|
|
if (student != null && course != null) { |
|
|
|
// If the course is not already enrolled |
|
|
|
if (!student.getCourseGrades().containsKey(course)) { |
|
|
|
student.getCourseGrades().put(course, "Not Graded"); |
|
|
|
System.out.println("Student " + studentId + " enrolled in course " + courseId + "."); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
System.out.println("Student " + studentId + " is already enrolled in course " + courseId + "."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (student == null) System.out.println("Student ID not found."); |
|
|
|
if (course == null) System.out.println("Course ID not found."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void enrollProfInCourse(){ |
|
|
|
|
|
|
|
System.out.println("Please enter Professor ID"); |
|
|
@ -507,24 +478,35 @@ public class Administration { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public boolean assignGradeToStudent(String studentId, String courseId, String grade) { |
|
|
|
public void createCourse(String courseName, String courseID, int credits) { |
|
|
|
// Check if a course with the given ID already exists |
|
|
|
if (findCourseByID(courseID) != null) { |
|
|
|
System.out.println("A course with ID " + courseID + " already exists."); |
|
|
|
} else { |
|
|
|
Course newCourse = new Course(courseName, courseID, credits); |
|
|
|
courses.add(newCourse); |
|
|
|
System.out.println("Course " + courseName + " (" + courseID + ") created successfully."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public boolean enrollStudentInCourse(String studentId, String courseId) { |
|
|
|
Student student = findStudentById(studentId); |
|
|
|
// First, find the course by ID to ensure it exists in the system. |
|
|
|
Course course = findCourseByID(courseId); |
|
|
|
|
|
|
|
if (student != null && course != null) { |
|
|
|
// Check if the student is enrolled in the specified course. |
|
|
|
if (student.getCourseGrades().containsKey(course)) { |
|
|
|
// Student is enrolled in the course, proceed to assign the grade. |
|
|
|
student.getCourseGrades().put(course, grade); |
|
|
|
// If the course is not already enrolled |
|
|
|
if (!student.getCourseGrades().containsKey(course)) { |
|
|
|
student.getCourseGrades().put(course, "Not Graded"); |
|
|
|
System.out.println("Student " + studentId + " enrolled in course " + courseId + "."); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
// Student is not enrolled in the specified course. |
|
|
|
System.out.println("Student is not enrolled in the specified course."); |
|
|
|
System.out.println("Student " + studentId + " is already enrolled in course " + courseId + "."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (student == null) System.out.println("Student ID not found."); |
|
|
|
if (course == null) System.out.println("Course ID not found."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public void viewCourses() { |
|
|
@ -538,6 +520,27 @@ public class Administration { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean assignGradeToStudent(String studentId, String courseId, String grade) { |
|
|
|
Student student = findStudentById(studentId); |
|
|
|
// First, find the course by ID to ensure it exists in the system. |
|
|
|
Course course = findCourseByID(courseId); |
|
|
|
|
|
|
|
if (student != null && course != null) { |
|
|
|
// Check if the student is enrolled in the specified course. |
|
|
|
if (student.getCourseGrades().containsKey(course)) { |
|
|
|
// Student is enrolled in the course, proceed to assign the grade. |
|
|
|
student.getCourseGrades().put(course, grade); |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
// Student is not enrolled in the specified course. |
|
|
|
System.out.println("Student is not enrolled in the specified course."); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|