diff --git a/src/src/domain/Student.java b/src/src/domain/Student.java index bcd39df..cc5eb40 100644 --- a/src/src/domain/Student.java +++ b/src/src/domain/Student.java @@ -48,7 +48,8 @@ public void editStudentInformation(){ //학생이름, 학생아이디 출력 public void printStudentInformation(){ - System.out.println("이름: " + name + ", 아이디: " + id); + System.out.println("이름: " + name + ", 아이디: " + id ); + System.out.println("***********************"); } public void printDetailStudentInformation(){ diff --git a/src/src/service/AdminService.java b/src/src/service/AdminService.java index 34846a7..efcce50 100644 --- a/src/src/service/AdminService.java +++ b/src/src/service/AdminService.java @@ -82,7 +82,6 @@ public void bankSystem() throws IOException { System.out.println("* " + name + " *"); System.out.println("*********************"); } - } //수정할 수 있는 수정메뉴 출력 @@ -111,18 +110,27 @@ public boolean showTeacherInformation(String teacherId) throws IOException { public void showStudentList() throws IOException { List StudentList = studentRepository.findAll(); + System.out.println(" [학생리스트] "); + System.out.println("***********************"); for (Student student : StudentList) { student.printStudentInformation(); } } - //1. 학생상세정보출력 - public void showDetailStudentList() throws IOException { - List StudentList = studentRepository.findAll(); + //학생아이디가 존재하는지 확인 + public boolean isExistStudent(String studentId) { + return studentRepository.isExist(studentId); + } - for (Student student : StudentList) { - student.printDetailStudentInformation(); + //1. (입력받은 아이디의 학생)상세정보출력 + public boolean detailStudentInformation(String studentId) throws IOException { + Student student = studentRepository.findById(studentId); + if(student == null) { + System.out.println("입력 아이디에 해당하는 학생정보가 없습니다."); + return false; } + student.printDetailStudentInformation(); + return true; } //2. 학생정보 수정 @@ -154,16 +162,17 @@ public void newEditStudentInformation(String studentId, int option, String value } //학생정보 삭제 - public void deleteStudentInformation() throws IOException { - Scanner sc = new Scanner(System.in); - System.out.println("삭제하실 학생의 아이디를 입력해주세요: "); - - String StudentId = sc.nextLine();//삭제할 학생의 아이디 입력 - Student targetDeleteStudent = studentRepository.findById(StudentId); - studentRepository.delete(targetDeleteStudent); + public boolean newDeleteStudentInformation(String studentId) throws IOException { + Student student = studentRepository.findById(studentId); + if(student == null) { + System.out.println("입력 아이디에 해당하는 학생정보가 없습니다."); + return false; + } + studentRepository.delete(student); System.out.println("입력하신 학생의정보가 삭제되었습니다."); studentRepository.save(); + return true; } //첫번째화면 - 강사정보출력(기능은 아님) - 이름, 아이디만 @@ -175,13 +184,15 @@ public void showTeacherList() throws IOException { } } - //1. 강사상세정보 출력 - public void showDetailTeacherList() throws IOException { - List TeacherList = teacherRepository.findAll(); - - for (Teacher teacher : TeacherList) { - teacher.printDetailTeacherInformation(); + //1. (입력받은 아이디의 강사)상세정보출력 + public boolean detailTeacherInformation(String teacherId) throws IOException { + Teacher teacher = teacherRepository.findById(teacherId); + if(teacher == null) { + System.out.println("입력 아이디에 해당하는 강사정보가 없습니다."); + return false; } + teacher.printDetailTeacherInformation(); + return true; } //2. 강사정보 수정 @@ -212,6 +223,20 @@ public void newEditTeacherInformation(String teacherId, int option, String value } } + //강사정보 삭제 + public boolean newDeleteTeacherInformation(String teacherId) throws IOException { + Teacher teacher = teacherRepository.findById(teacherId); + if(teacher == null) { + System.out.println("입력 아이디에 해당하는 강사정보가 없습니다."); + return false; + } + teacherRepository.delete(teacher); + System.out.println("입력하신 강사의정보가 삭제되었습니다."); + + teacherRepository.save(); + return true; + } + //첫번째화면 - 강의정보출력(기능은 아님) public void showLectureList() throws IOException { List LectureList = lectureRepository.findAll(); @@ -230,6 +255,17 @@ public void showDetailLectureList() throws IOException { } } + //1. (입력받은 아이디의 학생)상세정보출력 + public boolean detailLectureInformation(String lectureId) throws IOException { + Lecture lecture = lectureRepository.findById(lectureId); + if(lecture == null) { + System.out.println("입력 아이디에 해당하는 학생정보가 없습니다."); + return false; + } + lecture.printDetailLectureInformation(); + return true; + } + //2.새로운 강의 등록 public void registerLecture(String name,int day,int time, String teacherName, String teacherId) throws IOException { @@ -256,6 +292,7 @@ public boolean isExistTeacher(String teacherId) { //강사 아이디로 강사 이름반환 public String getTeacherName(String teacherId) throws IOException { + return teacherRepository.findById(teacherId).getName(); } @@ -270,4 +307,18 @@ public void deleteLectureInformation() throws IOException { System.out.println("입력하신 강의정보가 삭제되었습니다."); lectureRepository.save(); } + + //강의정보 삭제 + public boolean newDeleteLectureInformation(String lectureId) throws IOException { + Lecture lecture = lectureRepository.findById(lectureId); + if(lecture == null) { + System.out.println("입력 아이디에 해당하는 강의정보가 없습니다."); + return false; + } + lectureRepository.delete(lecture); + System.out.println("입력하신 강사의정보가 삭제되었습니다."); + + lectureRepository.save(); + return true; + } }