Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[안예성] 과제 제출합니다 #1

Open
wants to merge 18 commits into
base: yeseong
Choose a base branch
from
Open
14 changes: 8 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Template의 역할에 대해 알아보세요
그리구 여기서 이 파일을 수정했을 때 실제로 나타나지 않은 이유에 대해서도 생각해보시면 좋을 것 같아요

Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ PR의 제목은 '[이름] 과제 제출합니다'로 통일해주세요.

## 1. 구현 여부
### 요구사항 구현 여부 *
- [ ] 학생은 원서를 제출할 수 있습니다.
- [ ] 학교는 받은 원서를 점수 순으로 다음 정보를 확인할 수 있습니다.
- [X] 학생은 원서를 제출할 수 있습니다.
- [X] 학교는 받은 원서를 점수 순으로 다음 정보를 확인할 수 있습니다.
- 지원자의 이름, 전화번호, 출신 중학교
- 지원자의 성적, 출결, 가산점
- [ ] 학생은 자신이 제출한 원서의 상태를 확인할 수 있습니다.
- [X] 학생은 자신이 제출한 원서의 상태를 확인할 수 있습니다.

### 제한 사항 구현 여부 *
- [ ] 원서는 한 번만 제출할 수 있습니다.
- [X] 원서는 한 번만 제출할 수 있습니다.

### 테스트
- [ ] (진행한 테스트 케이스를 모두 적어주세요)
Expand All @@ -32,10 +32,12 @@ PR의 제목은 '[이름] 과제 제출합니다'로 통일해주세요.

## 2. 진행 중 느낀점
### 과제를 진행하며 한 고민들 *
- (고민들을 모두 적어주세요)
- class를 어떤 식으로 나눠야 하는지 고민하였습니다.
- 학생 데이터를 어떤 형식으로 저장을 해야하는지 생각한 후 무슨 컬렉션 프레임워크를 써야할지 고민했습니다.

### 발생한 이슈와 해결 방법
- (발생한 이슈와 해결 방법을 모두 적어주세요)
- 자신의 원서를 조회할 때 for문으로 자신의 이름과 일치하면 출력하는 형식으로 코드를 작성하였는데 이것이 비효율 적이라 생각하여 stream으로 이름을 필터링 하여 출력을 할 수 있도록 하였습니다.
- student의 멤버변수들을 static으로 생성하였는데 외부의 접근과 수정을 막기 위해 private로 변경하였다.

### 질문
- (질문을 모두 적어주세요)
100 changes: 29 additions & 71 deletions README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 파일도 마찬가지입니다!
README 파일에 역할에 대해 알아보세용

Original file line number Diff line number Diff line change
@@ -1,85 +1,43 @@
## 0️⃣ 과제 안내
<!--
## 0. 작성 참고 사항

> **원서 접수** 기능 구현하기
다음 템플릿의 내용을 모두 채운 후 제출해주세요.
> 제목 옆 별표(*) 표시가 없다면 선택사항이므로 채우지 않아도 됩니다.

### 사용 기술
PR의 제목은 '[이름] 과제 제출합니다'로 통일해주세요.
(예시) [김한울] 과제 제출합니다

- Java 11
해당 PR을 바탕으로 면접을 진행할 예정입니다. 성실하게 작성해주세요.
또한 모든 인턴 선발을 마친 후 지원자 모두의 PR에 리뷰를 해드릴 예정입니다.
리뷰 반영은 선택 사항이니 참고 바랍니다.

### 기능 요구사항
해당 에디터가 어렵다면 markdown을 키워드로 검색해서 알아보세요!
-->

- [ ] 학생은 원서를 제출할 수 있습니다.
- [ ] 학교는 받은 원서를 점수 순으로 다음 정보를 확인할 수 있습니다.
## 1. 구현 여부
### 요구사항 구현 여부 *
- [X] 학생은 원서를 제출할 수 있습니다.
- [X] 학교는 받은 원서를 점수 순으로 다음 정보를 확인할 수 있습니다.
- 지원자의 이름, 전화번호, 출신 중학교
- 지원자의 성적, 출결, 가산점
- [ ] 학생은 자신이 제출한 원서의 상태를 확인할 수 있습니다.
- [X] 학생은 자신이 제출한 원서의 상태를 확인할 수 있습니다.

### 제한 사항
### 제한 사항 구현 여부 *
- [X] 원서는 한 번만 제출할 수 있습니다.

- [ ] 원서는 한 번만 제출할 수 있습니다.
### 테스트
- [ ] (진행한 테스트 케이스를 모두 적어주세요)

<br>

## 1️⃣ 제출 방법
## 2. 진행 중 느낀점
### 과제를 진행하며 한 고민들 *
- class를 어떤 식으로 나눠야 하는지 고민하였습니다.
- 학생 데이터를 어떤 형식으로 저장을 해야하는지 생각한 후 무슨 컬렉션 프레임워크를 써야할지 고민했습니다.

1. 이 레포지토리를 포크합니다.
2. 본인의 이름으로 브랜치를 만듭니다. (예시: hanul)
3. 메인 함수의 주석을 읽으며 코드를 작성해 주세요.
4. 테스트 코드를 작성해주세요. (선택 사항, 가산점 부여)
5. 3번과 4번 과정을 진행하며 커밋해주세요. (밑 커밋 규칙 참고)
6. 모두 완료한 후 Pull Request를 보내주세요.
### 발생한 이슈와 해결 방법
- 자신의 원서를 조회할 때 for문으로 자신의 이름과 일치하면 출력하는 형식으로 코드를 작성하였는데 이것이 비효율 적이라 생각하여 stream으로 이름을 필터링 하여 출력을 할 수 있도록 하였습니다.
- student의 멤버변수들을 static으로 생성하였는데 외부의 접근과 수정을 막기 위해 private로 변경하였다.

> **포크, 브랜치, Pull Request가 뭔지 모르겠다면?** <br>
다음 글을 참고하면서 진행해주세요!<br>
꼭 이 글이 아니더라도, 다른 글들을 참고하면서 해도 괜찮습니다.<br>
[Git을 이용한 협업: Fork 부터 Pull Request 까지](https://seungwubaek.github.io/tools/git/contributing_using_pull_request/)

<br>

## 2️⃣ 평가 기준

| 항목 | 내용 | 비율 |
| --- | --- | --- |
| 코드 가독성 | 코드가 얼마나 술술 잘 읽히는가 | 30% |
| 실행 | 기능이 문제 없이 실행되는가 | 30% |
| 학구열 | 자기주도적으로 모르는 내용을 찾아보며 개발했는가 | 30% |
| 성실성 | 성실한가 | 10% |
| 테스트 | 테스트 코드 작성시 가산점 부여 | 3% (추가) |

<br>


## 3️⃣ 커밋 메시지 규칙

### 형식
```
Type :: Title

Body
```

### 상세 규칙
- 헤더는 type을 지정해 주고, title을 명령문으로 작성한다.
- 헤더는 너무 길지 않도록 한다.
- Body에는 해당 커밋에서 무엇을 왜 하였는지 구체적으로 서술한다.
- Footer는 선택사항.
- 원활한 소통을 위해 한글로 작성한다.

### Header Type
| type | description |
| --- | --- |
| ADD | 새로운 기능 |
| FIX | 버그 수정 |
| REFACTOR | 코드 리팩토링 |
| TEST | 테스트 코드 작성 |
| SET | 프로젝트 세팅 |
| CHORE | 자잘한 일 |
| DOCS | 문서 추가 |
| DELETE | 삭제 |

### 명령어 예시
```bash
git commit -m "ADD :: 원서 객체
- ~~ 구체적인 설명
"
```
### 질문
- (질문을 모두 적어주세요)
33 changes: 18 additions & 15 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
import school.School;
import student.Student;

public class Main {
public static void main(String[] args) {

// TODO-0 데이터 생성
// 부산소프트웨어마이스터고등학교를 생성합니다.

School bssm = new School();
// 밤돌중학교를 다니고 있는 이밤돌 학생을 생성합니다.

Student leebamdol = new Student();
// 곰돌중학교를 다니고 있는 금곰돌 학생을 생성합니다.

Student geumgomdol = new Student();

// TODO-1 이밤돌 학생 원서
// 이밤돌 학생이 부산소프트웨어마이스터고등학교에 낼 원서를 작성합니다.

leebamdol.setData("이밤돌", "01012345678", "알이중학교", 52, 9, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 School 객체를 만든 만큼 중학교 넣을 때도 School 객체를 사용했으면 더 좋았을 것 같아요

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그리고 setData같은 네이밍은 의미가 잘 드러나지 않아요
이 메서드가 해야 하는 역할은 원서를 작성하는 건데, 이밤돌씨 객체에 데이터를 넣어주고 있으니까요.
그리고 이렇게 그냥 모든 값을 넣어주는 메서드는 생성자에 넣는 게 깔끔할 듯 하네요

// 이밤돌 학생이 원서를 제출합니다.

bssm.submit(leebamdol.getData());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기두 마찬가지입니다!
원서를 제출해야 하는데 getData() 메서드를 호출하고 있죠.
원서 제출 = 데이터 가져오기 의미가 맞지 않아요


// TODO-2 금곰돌 학생 원서
// 금곰돌 학생이 부산소프트웨어마이스터고등학교에 낼 원서를 작성합니다.

geumgomdol.setData("금곰돌", "01087654321", "소리중학교", 79, 10, 6);
// 금곰돌 학생이 원서를 제출합니다.

bssm.submit(geumgomdol.getData());

// TODO-3 이밤돌 학생 원서 재제출
// 이밤돌 학생이 부산소프트웨어마이스터고등학교에 낼 원서를 작성합니다.

leebamdol.setData("이밤돌", "01012345678", "아리중학교", 52, 9, 2);
// 이밤돌 학생이 원서를 제출합니다.
// 원서는 정상적으로 처리하지 않고, 한 번만 제출할 수 있다는 메시지를 출력합니다.

bssm.submit(leebamdol.getData());

// TODO-4 원서 조회
// 제출한 모든 원서를 점수 순을 조회합니다.

bssm.search();

// TODO-5 합불 여부 입력
// 자유롭게 기준을 세워서 그 기준에 따라 이밤돌 학생은 탈락으로, 금곰돌 학생은 합격으로 처리합니다.

bssm.pass();

// TODO-6 자신의 원서 상태 조회
// 이밤돌 학생이 본인의 원서 상태를 조회합니다.

bssm.check(leebamdol.getName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

본인의 원서 상태 조회는 이렇게 bssm 객체에 의존하지 말고, leebamdol 객체에서 책임지는 게 논리상 좋겠네요

// 금곰돌 학생이 본인의 원서 상태를 조회합니다.

bssm.check(geumgomdol.getName());
}
}
}
49 changes: 49 additions & 0 deletions src/school/School.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package school;

import student.Student;

import java.util.ArrayList;

public class School {
static ArrayList<Student> studentsData = new ArrayList<>();

// 제출 내용 저장
public static void submit(ArrayList<Student> obj) {
if (obj != null) studentsData.addAll(obj); // 데이터가 포함 되어 있으면 저장
}
Comment on lines +11 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파라미터에 obj 같은 의미없는 변수명은 지양해야 합니다.
의미를 알기 어려우니까요. 차라리 studentList 정도로 쓰는 게 좋겠네요.
근데 하나 궁금한 게 제출 내용을 저장할 떄 List로 들어올 일이 있나요?


// 점수 순으로 출력
public static void search() {
studentsData.sort((student1, student2) -> Integer.compare(student2.getScore(), student1.getScore()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

비교하는 부분 좋네요

for(Student student : studentsData) {
System.out.println(student);
}
}

// 합불 여부 처리
public static void pass() {
for (Student student : studentsData) {
// 합격 기준 : / 성적 80% / 출결 10% / 가산점 10% /
if (student.getScore() * 0.8 + student.getAttendance() + student.getPoint() >= 70)
student.setPass(true);
}
}

// 본인의 원서 조회
public static void check(String name) {
studentsData.stream()
.filter(student -> name.equals(student.getName()))
.forEach(student -> {
System.out.println("==================================");
System.out.println(student.getName() + "의 원서접수 내용");
System.out.println("==================================");
System.out.println("지원자 이름 : " + student.getName());
System.out.println("전화번호 : " + student.getTel());
System.out.println("출신 중학교 : " + student.getNativeSC());
System.out.println("성적 : " + student.getScore());
System.out.println("출결 : " + student.getAttendance());
System.out.println("가산점 : " + student.getPoint());
System.out.println("지원자의 합격 여부 : " + student.isPass());
});
}
Comment on lines +11 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드들 왜 static으로 선언했나요? static으로 안 해도 동작할 것 같은데?

}
124 changes: 124 additions & 0 deletions src/student/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package student;

import java.util.ArrayList;

public class Student {
private String name; // 이름
private String tel; // 전화번호
private String nativeSC; // 출신 중학교
private int score; // 성적
private int attendance; // 출결
private int point; // 가산
private boolean submit = false; // 제출 여부
private boolean pass = false; // 합불 여부
private ArrayList<Student> studentData = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수 이름을 제출 이력 쯤으로 두는 게 좋을 것 같아요.


public Student() {}

public Student(String name, String tel, String nativeSC, int score, int attendance, int point, boolean pass) {
this.name = name;
this.tel = tel;
this.nativeSC = nativeSC;
this.score = score;
this.attendance = attendance;
this.point = point;
}

// 학생의 원서 저장
public void setData(String name, String tel, String nativeSC, int score, int attendance, int point) {
Comment on lines +27 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

원서와 학생 객체를 나누는 게 좋겠네요

this.name = name;
this.tel = tel;
this.nativeSC = nativeSC;
this.score = score;
this.attendance = attendance;
this.point = point;
Student setStudentData = new Student(name, tel, nativeSC, score, attendance, point, pass);
studentData.add(setStudentData); // studentData에 받은 데이터 저장
}

// 학생 데이터 반환
public ArrayList<Student> getData() {
if (!submit) { // 제출을 한번도 하지 않았을 경우
submit = true;
return studentData;
}
else { // 제출을 한번이라도 한 경우 null return
System.out.println(getName() + "님 이미 제출하였습니다.");
return null;
}
}
Comment on lines +39 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 메서드의 역할이 이상해요.
호출 시점이 정해져 있다고 해야하나?
차라리 setData() 메서드에서 submit을 true로 만들어주는 게 좋지 않을까요?


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getTel() {
return tel;
}

public void setTel(String tel) {
this.tel = tel;
}

public String getNativeSC() {
return nativeSC;
}

public void setNativeSC(String nativeSC) {
this.nativeSC = nativeSC;
}

public int getScore() {
return score;
}

public void setScore(int score) {
this.score = score;
}
Comment on lines +79 to +81
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setter는 남용하지 않아야 합니다
관련 키워드로 검색해보세용


public int getAttendance() {
return attendance;
}

public void setAttendance(int attendance) {
this.attendance = attendance;
}

public int getPoint() {
return point;
}

public void setPoint(int point) {
this.point = point;
}

public boolean isSubmit() {
return submit;
}

public void setSubmit(boolean submit) {
this.submit = submit;
}

public boolean isPass() {
return pass;
}

public void setPass(boolean pass) {
this.pass = pass;
}

@Override
public String toString() {
return "Name: " + name +
", Tel: " + tel +
", NativeSC: " + nativeSC +
", Score: " + score +
", Attendance: " + attendance +
", Point: " + point;
}
}