Skip to content

Commit

Permalink
#48 [refactor] domain 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
hamings committed Mar 27, 2024
1 parent e735b19 commit 8ff08b9
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 105 deletions.
6 changes: 3 additions & 3 deletions src/src/domain/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class Admin {
private String id;
private String password;

private Admin(){
private Admin() {
this.id = "admin";
this.password = "admin123";
}

public static Admin getInstance(){
if(admin==null){
public static Admin getInstance() {
if (admin == null) {
admin = new Admin();
}
return admin;
Expand Down
103 changes: 51 additions & 52 deletions src/src/domain/AmsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,39 @@ public void run() throws IOException {
num = scanner.nextLine();
switch (num) {
case "1": {
while(true){
Constant.printRegistrationLectureMenu();
Constant.printInputText();
num = scanner.nextLine();
if (num.equals("1")) { //수강신청 선택
studentService.showAllLectureList();
// 원하는 강의 고르기
System.out.print("수강하고자 하는 강의의 강의 ID를 입력해주세요: \n");
while (true) {
Constant.printRegistrationLectureMenu();
Constant.printInputText();

String choiceLectureId = scanner.nextLine();
studentService.registerLecture(choiceLectureId);
} else if (num.equals("2")) { //수강신청 취소
if (studentService.showStudentAllRegistrationLecture()) {
System.out.println("취소하고자 하는 강의의 강의 ID를 입력해주세요: \n");
num = scanner.nextLine();
if (num.equals("1")) { //수강신청 선택
studentService.showAllLectureList();
// 원하는 강의 고르기
System.out.print("수강하고자 하는 강의의 강의 ID를 입력해주세요: \n");
Constant.printInputText();
String lectureId = scanner.nextLine();
studentService.deleteLecture(lectureId);
}

} else if (num.equals("3")) {
studentService.showStudentAllRegistrationLecture();
} else if (num.equals("0")) {
break;
} else {
//올바르지 않은 번호 선택
Constant.incorrectNumber();
}
String choiceLectureId = scanner.nextLine();
studentService.registerLecture(choiceLectureId);
} else if (num.equals("2")) { //수강신청 취소
if (studentService.showStudentAllRegistrationLecture()) {
System.out.println("취소하고자 하는 강의의 강의 ID를 입력해주세요: \n");
Constant.printInputText();
String lectureId = scanner.nextLine();
studentService.deleteLecture(lectureId);
}

} else if (num.equals("3")) {
studentService.showStudentAllRegistrationLecture();
} else if (num.equals("0")) {
break;
} else {
//올바르지 않은 번호 선택
Constant.incorrectNumber();
}
}
break;
}
case "2": {
while(true) {
while (true) {
studentService.showStudyRoom();
Constant.printStudyRoomMenu();
Constant.printInputText();
Expand All @@ -112,7 +112,7 @@ public void run() throws IOException {
Constant.printInputText();
String seatNum = scanner.nextLine();
studentService.cancelReservation(seatNum);
}else if(num.equals("0")){
} else if (num.equals("0")) {
break;
} else {
Constant.incorrectNumber();
Expand All @@ -126,7 +126,8 @@ public void run() throws IOException {
studentService.checkNotification();
System.out.println();
break;
} case "4": {
}
case "4": {
// 로그아웃
studentService.setStudent((Student) userService.logout());
System.out.println();
Expand All @@ -151,12 +152,12 @@ public void run() throws IOException {
case "1": {
System.out.println("-------------------------------[담당강의 리스트]-----------------------------------");
teacherService.showLectureList();
System.out.println("-----------------------------------------------------------------------------------------");
System.out.println("--------------------------------------------------------------------------------");
System.out.println();
break;
}
case "2": {
if(teacherService.isTeacherLectureListEmpty()){
if (teacherService.isTeacherLectureListEmpty()) {
System.out.println("[현재 담당하고있는 강의가 없습니다.]");
continue;
}
Expand Down Expand Up @@ -188,7 +189,7 @@ public void run() throws IOException {

switch (num) {
case "1": {
while(true) {
while (true) {
adminService.showStudentList();
Constant.printStudentInformationMenu();
Constant.printInputText();
Expand All @@ -199,16 +200,16 @@ public void run() throws IOException {
editStudentInformation();
} else if (num.equals("3")) { //학생 삭제
deleteStudentInformation();
} else if(num.equals("0")){
} else if (num.equals("0")) {
break;
}else {
} else {
Constant.incorrectNumber();
}
}
break;
}
case "2": {
while(true) {
while (true) {
adminService.showTeacherList();
Constant.printTeacherInformationMenu();
Constant.printInputText();
Expand All @@ -218,7 +219,7 @@ public void run() throws IOException {
showDetailTeacher();
} else if (num.equals("2")) { //강사 수정
editTeacherInformation();
} else if (num.equals("0")) { //뒤로 가기
} else if (num.equals("0")) { //뒤로 가기
break;
} else {
Constant.incorrectNumber();
Expand All @@ -227,7 +228,7 @@ public void run() throws IOException {
break;
}
case "3": {
while(true) {
while (true) {
adminService.showLectureList();
Constant.printLectureInfromationMenu();
Constant.printInputText();
Expand Down Expand Up @@ -405,7 +406,7 @@ public void showDetailStudent() throws IOException {
System.out.println("[상세정보를 확인하실 학생의 아이디 (뒤로가기: 0번)]");
Constant.printInputText();
studentId = scanner.nextLine();
if(studentId.equals("0"))
if (studentId.equals("0"))
return;
System.out.println("*********************************");
if (adminService.detailStudentInformation(studentId))
Expand All @@ -421,7 +422,7 @@ public void editStudentInformation() throws IOException {
System.out.println("[수정하실 학생의 아이디 (뒤로가기: 0번)]");
Constant.printInputText();
studentId = scanner.nextLine();
if(studentId.equals("0")){
if (studentId.equals("0")) {
return;
}
System.out.println("**********************************");
Expand Down Expand Up @@ -512,7 +513,7 @@ public void deleteStudentInformation() throws IOException {
System.out.println("[삭제하실 학생의 아이디 (뒤로가기: 0번)]");
Constant.printInputText();
studentId = scanner.nextLine();
if(studentId.equals("0")){
if (studentId.equals("0")) {
return;
}
System.out.println("*****************************************");
Expand All @@ -526,11 +527,11 @@ public void showDetailTeacher() throws IOException {
System.out.println("*********************************");
String teacherId;

while(true) {
while (true) {
System.out.println("[상세정보를 확인하실 강사의 아이디 (뒤로가기: 0번)]");
Constant.printInputText();
teacherId = scanner.nextLine();
if(teacherId.equals("0"))
if (teacherId.equals("0"))
return;
System.out.println("*********************************");
if (adminService.detailTeacherInformation(teacherId))
Expand All @@ -544,11 +545,11 @@ public void editTeacherInformation() throws IOException {
System.out.println("**********************************");
String teacherId;

while(true) {
while (true) {
System.out.println("[수정하실 강사의 아이디 (뒤로가기: 0번)]: ");
Constant.printInputText();
teacherId = scanner.nextLine();
if(teacherId.equals("0"))
if (teacherId.equals("0"))
return;
System.out.println("*********************************************");
if (adminService.showTeacherInformation(teacherId)) break; // 수정할 학생 찾음
Expand Down Expand Up @@ -624,11 +625,11 @@ public void deleteTeacherInformation() throws IOException {
System.out.println("**********************************");
String teacherId;

while(true) {
while (true) {
System.out.println("[삭제하실 강사의 아이디 (뒤로가기: 0번)]");
Constant.printInputText();
teacherId = scanner.nextLine();
if(teacherId.equals("0")) return;
if (teacherId.equals("0")) return;
System.out.println("**********************************");
if (adminService.newDeleteTeacherInformation(teacherId))
break;
Expand All @@ -640,11 +641,11 @@ public void showDetailLecture() throws IOException {
System.out.println("**********************************");
String lectureId;

while(true) {
while (true) {
System.out.println("[상세정보를 확인하실 강의 아이디 (뒤로가기 0번)]");
Constant.printInputText();
lectureId = scanner.nextLine();
if(lectureId.equals("0")){
if (lectureId.equals("0")) {
return;
}
System.out.println("**********************************");
Expand Down Expand Up @@ -731,15 +732,13 @@ public void deleteLectureInformation() throws IOException {
System.out.println("**********************************");
String lectureId;

while(true) {
while (true) {
System.out.println("[삭제하실 강의 아이디 (뒤로가기: 0번)]");
Constant.printInputText();
lectureId = scanner.nextLine();
if(lectureId.equals("0")) return;
if(adminService.newDeleteLectureInformation(lectureId))
if (lectureId.equals("0")) return;
if (adminService.newDeleteLectureInformation(lectureId))
break;
}
}


}
22 changes: 11 additions & 11 deletions src/src/domain/Bank.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Bank {
private static List<Account> accountList;
private static int successCount;

static{
static {
accountList = new ArrayList<>();
accountList.add(new Account("111-11-1", "1234", 1000000L));
accountList.add(new Account("222-22-2", "1234", 1000000L));
Expand All @@ -19,21 +19,21 @@ public class Bank {
}

//결제승인체크(학생계좌번호, 계좌비밀번호 맞는지 체크)
public boolean checkAccount(String accountNumber, String accountPassword){
public boolean checkAccount(String accountNumber, String accountPassword) {
for (Account account : accountList) {
if(account.getAccountNumber().equals(accountNumber) && account.getAccountPassword().equals(accountPassword)){
if (account.getAccountNumber().equals(accountNumber) && account.getAccountPassword().equals(accountPassword)) {
return true;
}
}
return false;
}

//학생학원비결제 진행
public boolean paymentAccount(String accountNumber, Long lectureCost) {
public boolean accountTransfer(String accountNumber, Long lectureCost) {
for (Account account : accountList) {
if(account.getAccountNumber().equals(accountNumber)){
if(account.getBalance() >= lectureCost) {
account.setBalance(account.getBalance() - lectureCost );
if (account.getAccountNumber().equals(accountNumber)) {
if (account.getBalance() >= lectureCost) {
account.setBalance(account.getBalance() - lectureCost);
return true;
} else return false;
}
Expand All @@ -42,19 +42,19 @@ public boolean paymentAccount(String accountNumber, Long lectureCost) {
}

//학생잔액조회
public long finalBalance(String accountNumber){
public long getBalance(String accountNumber) {
for (Account account : accountList) {
if(account.getAccountNumber().equals(accountNumber)){
if (account.getAccountNumber().equals(accountNumber)) {
return account.getBalance();
}
}
return 0;
}

//효성은행에 존재하는 계좌인지 체크
public boolean checkAmsAccount(String accountNumber){
public boolean checkAmsAccount(String accountNumber) {
for (Account account : accountList) {
if(account.equals(accountNumber)){
if (account.equals(accountNumber)) {
return true;
}
}
Expand Down
29 changes: 14 additions & 15 deletions src/src/domain/Lecture.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

@Data
public class Lecture implements Serializable {
public class Lecture implements Serializable {
private String lectureId; //강의아이디
private String lectureName;//강의이름
private int lectureDay;//강의요일
Expand All @@ -29,39 +29,38 @@ public Lecture(String lectureId, String lectureName, int lectureDay, int lecture
this.lectureTeacherName = lectureTeacherName;
this.lectureTeacherId = lectureTeacherId;
this.lectureRegistrationIdList = new ArrayList<>();
this.lectureRegistrationList = new ArrayList<>();
}

public void printLectureInformation(){

public void printLectureInformation() {
System.out.println("이름: " + lectureName + ", 아이디: " + lectureId);
System.out.println("*********************************************");
}

public void printDetailLectureInformation(){

public void printDetailLectureInformation() {
String realLectureDay = "";
if(lectureDay == 0){
if (lectureDay == 0) {
realLectureDay = "월요일";
} else if(lectureDay == 1){
} else if (lectureDay == 1) {
realLectureDay = "화요일";
} else if(lectureDay == 2){
} else if (lectureDay == 2) {
realLectureDay = "수요일";
} else if(lectureDay == 3){
} else if (lectureDay == 3) {
realLectureDay = "목요일";
} else if(lectureDay == 4){
} else if (lectureDay == 4) {
realLectureDay = "금요일";
}

String realLectureTime = "";
if(lectureTime == 0){
if (lectureTime == 0) {
realLectureTime = "10:00 ~ 12:00";
} else if(lectureTime == 1){
} else if (lectureTime == 1) {
realLectureTime = "13:00 ~ 14:50";
} else if(lectureTime == 2){
} else if (lectureTime == 2) {
realLectureTime = "15:00 ~ 16:50";
} else if(lectureTime == 3){
} else if (lectureTime == 3) {
realLectureTime = "17:00 ~ 19:00";
}
System.out.println("이름: " + lectureName + ", 아이디: " + lectureId + ", 강의요일: " + realLectureDay + ", 강의시간: " + realLectureTime + ", 담당강사: " + lectureTeacherName);
System.out.println("이름: " + lectureName + ", 아이디: " + lectureId + ", 강의요일: " + realLectureDay + ", 강의시간: " + realLectureTime + ", 담당강사: " + lectureTeacherName);
}
}
2 changes: 1 addition & 1 deletion src/src/domain/LectureRegistration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LectureRegistration implements Serializable {
public class LectureRegistration implements Serializable {
//student - lecture의 중간 객체
private Long id;
private String lectureId;
Expand Down
Loading

0 comments on commit 8ff08b9

Please sign in to comment.