오버로딩 & 오버라이딩
오버로딩 : 같은 이름의 메서드를 다른 매개변수로 정의
오버라이딩 : 상위클래스에서 정의된 메서드를 재정의 해서 사용
public void createScore(){
int score = 0;
System.out.println("수강생 번호를 입력하세요 : ");
String studentId = sc.next();
studentId = validationStudentId(studentId);
if(!studentId.equals("empty")){
int count = 0;
ArrayList<Subject> sub = new ArrayList<>();
for (Subject subject : InitData.getSubjectStore()) {
if(subject.getStudentId().equals(studentId)){
count++;
sub.add(subject);
System.out.println(count+"."+subject.getSubjectName() );
}
}
System.out.println("과목을 입력하새요 : ");
int selectNum = sc.nextInt();
Subject sub2 = null;
sub2 = sub.get(selectNum-1);
int times = getTestTimes(sub2.getStudentId(),sub2.getSubjectId());
System.out.println(sub2.getSubjectName());
System.out.println("점수를 입력하세요 : ");
score = sc.nextInt();
char rank = calculateGrade(score, Objects.requireNonNull(sub2).getSubjectType());
InitData.getScoreStore().add(new Score(InitData.sequence(InitData.getIndexTypeScore()),sub2.getSubjectId(),studentId,times,score,rank));
System.out.println("점수 등록 완료!!");
for (Score score1 : InitData.getScoreStore()) {
System.out.println(score1.getScore());
System.out.println(score1.getTimes());
System.out.println(score1.getScoreId());
System.out.println(score1.getRank());
}
}else{
System.out.println("없는 학생번호 입니다.");
}
}
int score = 0;
System.out.println("수강생 번호를 입력하세요 : ");
String studentId = sc.next();
studentId = validationStudentId(studentId);
if(!studentId.equals("empty")){
int count = 0;
ArrayList<Subject> sub = new ArrayList<>();
for (Subject subject : InitData.getSubjectStore()) {
if(subject.getStudentId().equals(studentId)){
count++;
sub.add(subject);
System.out.println(count+"."+subject.getSubjectName() );
}
}
System.out.println("과목을 입력하새요 : ");
int selectNum = sc.nextInt();
Subject sub2 = null;
sub2 = sub.get(selectNum-1);
int times = getTestTimes(sub2.getStudentId(),sub2.getSubjectId());
System.out.println(sub2.getSubjectName());
System.out.println("점수를 입력하세요 : ");
score = sc.nextInt();
char rank = calculateGrade(score, Objects.requireNonNull(sub2).getSubjectType());
InitData.getScoreStore().add(new Score(InitData.sequence(InitData.getIndexTypeScore()),sub2.getSubjectId(),studentId,times,score,rank));
System.out.println("점수 등록 완료!!");
for (Score score1 : InitData.getScoreStore()) {
System.out.println(score1.getScore());
System.out.println(score1.getTimes());
System.out.println(score1.getScoreId());
System.out.println(score1.getRank());
}
}else{
System.out.println("없는 학생번호 입니다.");
}
}
팀과제 점수등록 기능 구현
'TIL' 카테고리의 다른 글
(2024-05-09) 자바 심화특강, 자바 팀과제 완료 (0) | 2024.05.09 |
---|---|
(2024-05-08)자바 팀과제 협업,조회기능 (0) | 2024.05.09 |
(2024-05-03) 자바 팀과제 (0) | 2024.05.03 |
(2024-05-02) 팀 프로젝트 템플릿코드 분석및 구현 (0) | 2024.05.02 |
(2024-05-01)자바 개인 과제 리팩토링 (1) | 2024.05.01 |