|
@ -529,24 +529,27 @@ public class Administration { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean assignGradeToStudent(String studentId, String courseId, String grade) { |
|
|
|
|
|
|
|
|
public void assignGradeToStudent(Scanner scanner) { |
|
|
|
|
|
System.out.print("Enter Student ID: "); |
|
|
|
|
|
String studentId = scanner.next(); |
|
|
|
|
|
System.out.print("Enter Course ID: "); |
|
|
|
|
|
String courseId = scanner.next(); |
|
|
|
|
|
System.out.print("Enter Grade: "); |
|
|
|
|
|
String grade = scanner.next(); |
|
|
|
|
|
|
|
|
Student student = findStudentById(studentId); |
|
|
Student student = findStudentById(studentId); |
|
|
// First, find the course by ID to ensure it exists in the system. |
|
|
|
|
|
Course course = findCourseByID(courseId); |
|
|
Course course = findCourseByID(courseId); |
|
|
|
|
|
|
|
|
if (student != null && course != null) { |
|
|
if (student != null && course != null) { |
|
|
// Check if the student is enrolled in the specified course. |
|
|
|
|
|
|
|
|
// Assuming Student class has a method to add or update grade for a course |
|
|
if (student.getCourseGrades().containsKey(course)) { |
|
|
if (student.getCourseGrades().containsKey(course)) { |
|
|
// Student is enrolled in the course, proceed to assign the grade. |
|
|
|
|
|
student.getCourseGrades().put(course, grade); |
|
|
student.getCourseGrades().put(course, grade); |
|
|
return true; |
|
|
|
|
|
|
|
|
System.out.println("Grade assigned successfully."); |
|
|
} else { |
|
|
} else { |
|
|
// Student is not enrolled in the specified course. |
|
|
|
|
|
System.out.println("Student is not enrolled in the specified course."); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
System.out.println("Student " + studentId + " is not enrolled in course " + courseId + "."); |
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
System.out.println("Failed to assign grade. Ensure the student and course IDs are correct."); |
|
|
} |
|
|
} |
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void dropStudentFromCourse(String studentID, String courseID){ |
|
|
public void dropStudentFromCourse(String studentID, String courseID){ |
|
|