Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
21 changes: 10 additions & 11 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
<br>

## 기능 요구사항
- [ ] 탐사선은 탐사 대원을 가질 수 있습니다.
- [ ] 탐사선은 다음과 같은 속성을 가집니다.
- 이름, 모델, 탐사 임무, 연료 수준
- [ ] 탐사선의 연료을 충전할 수 있습니다.
- [ ] 탐사선의 연료를 소모할 수 있습니다.
- 이름
- [ ] 탐사선의 이름을 변경할 수 있습니다.
- [ ] 무인 탐사선은 탐사 대원을 가질 수 없습니다.
- [ ] 유인 탐사선은 탐사 대원을 가질 수 있습니다.
- [ ] 탐사선의 정보를 확인할 수 있습니다.
- [ ] 탐사 대원은 여러대의 탐사선에 탑승할 수 있습니다.
- 탐사선 정보, 탐사 대원 등
- [ ] 탐사 대원은 탐사선에 탑승할 수 있습니다.
- [ ] 탐사 대원은 탐사선에서 내릴 수 있습니다.
- [ ] 탐사 대원은 다음과 같은 속성을 가집니다.
- 이름, 대원 ID, 소속된 탐사선 목록
- [ ] 탐사 대원의 정보를 확인할 수 있습니다.
- 이름
- [ ] 탐사 대원의 이름을 변경할 수 있습니다.

## 제한 사항
- [ ] 연료가 모두 충전되면 연료를 충전할 수 없습니다.
- [ ] 연료가 모두 소모되면 연료를 소모할 수 없습니다.
- [ ] 연료는 양으로 충전할 수도 있고, 퍼센트로 충전할 수도 있습니다.
- [ ] 연료는 양으로 소모할 수도 있고, 퍼센트로 소모할 수도 있습니다.
- [ ] 모든 변수는 'private'으로 선업합니다.
- [ ] 각각의 변수는 'getter', 'setter'로 접근 합니다.

## 코드 작성 시 유의사항
- [ ] 클래스별로 파일을 구분해야 합니다.
Expand Down
54 changes: 25 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
# 1️⃣ 과제안내
> 당신은 우주 탐사 관리 시스템을 개발하는 소프트웨어 개발자로 고용되었습니다. 탐사선과 탐사 대원들을 관리하는 시스템을 구현하는 것이 당신의 첫 번째 과제입니다. 다음 요구사항을 충족하는 클래스를 작성하세요.
>
# 1️⃣ 과제 안내
> 당신은 유인 및 무인 우주 탐사선 시스템을 개발하는 소프트웨어 개발자로 고용되었습니다. 유인 및 무인 탐사선 시스템을 구현하는 것이 당신의 첫 번째 과제입니다. 다음 요구사항을 충족하는 클래스를 작성하세요.

<br>

## 기능 요구사항
- [ ] 탐사선은 탐사 대원을 가질 수 있습니다.
## 2️⃣ 기능 요구 사항
- [ ] 탐사선은 다음과 같은 속성을 가집니다.
- 이름, 모델, 탐사 임무, 연료 수준
- [ ] 탐사선의 연료을 충전할 수 있습니다.
- [ ] 탐사선의 연료를 소모할 수 있습니다.
- 이름
- [ ] 탐사선의 이름을 변경할 수 있습니다.
- [ ] 무인 탐사선은 탐사 대원을 가질 수 없습니다.
- [ ] 유인 탐사선은 탐사 대원을 가질 수 있습니다.
- [ ] 탐사선의 정보를 확인할 수 있습니다.
- [ ] 탐사 대원은 여러대의 탐사선에 탑승할 수 있습니다.
- 탐사선 정보, 탐사 대원 등
- [ ] 탐사 대원은 탐사선에 탑승할 수 있습니다.
- [ ] 탐사 대원은 탐사선에서 내릴 수 있습니다.
- [ ] 탐사 대원은 다음과 같은 속성을 가집니다.
- 이름, 대원 ID, 소속된 탐사선 목록
- [ ] 탐사 대원의 정보를 확인할 수 있습니다.
- 이름
- [ ] 탐사 대원의 이름을 변경할 수 있습니다.

## 제한 사항
- [ ] 연료는 0보다 작을 수 없고 300보다 클 수 없습니다.
- [ ] 연료가 모두 충전되면 연료를 충전할 수 없습니다.
- [ ] 연료가 모두 소모되면 연료를 소모할 수 없습니다.
- [ ] 연료는 양으로 충전할 수도 있고, 퍼센트로 충전할 수도 있습니다.
- [ ] 연료는 양으로 소모할 수도 있고, 퍼센트로 소모할 수도 있습니다.
- [ ] 모든 변수는 'private'으로 선업합니다.
- [ ] 각각의 변수는 'getter', 'setter'로 접근 합니다.

## 코드 작성 시 유의사항
- [ ] 클래스별로 파일을 구분해야 합니다.
- [ ] 패키지, 변수, 메서드 작성시에는 꼭 그에 알맞는 네이밍 컨벤션을 따라야 합니다.

## 예시 출력 결과
```java
탐사 대원 Neil의 정보:

소속된 탐사선:
- Apollo 탐사선
- 모델: Model-X
- 임무: 태양계 탐사
- 연료 수준: 130

- Odyssey 탐사선
- 모델: Voyager
- 임무: 외계 생명체 탐사
- 연료 수준: 190
Spaceship: Voyager 1
우주선 속 탐사대원이 존재하지 않습니다.

Spaceship: BSSM 1
우주선 속 탐사대원이 존재하지 않습니다.

Spaceship: Apollo 11
Neil Armstrong 우주대원이 탐사 중 입니다.

Spaceship: Apollo 11
OYC 우주대원이 탐사 중 입니다.
```

<br>
Expand Down Expand Up @@ -90,7 +86,7 @@ git commit

"**무엇**"을 변경했는지를 작성합니다.

- 명령형, 현재 시제 사용: "변경"으로 작성 ("변경함", "변경했음" X)
- 명령형, 현재 시제 사용 (예시): "변경"으로 작성 ("변경함", "변경했음" X)
- 끝에 마침표(.) 금지
- 한글 사용 권장

Expand Down
Binary file added second/.DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions second/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
3 changes: 3 additions & 0 deletions second/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions second/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions second/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions second/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added second/out/production/second/Astronaut.class
Binary file not shown.
Binary file added second/out/production/second/Main.class
Binary file not shown.
Binary file added second/out/production/second/Spaceship.class
Binary file not shown.
18 changes: 18 additions & 0 deletions second/src/Astronaut.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class Astronaut {
private String astronautName; //탐사 대원 이름

Astronaut (String astronautName){
this.astronautName = astronautName;
}

Astronaut(){}

void setAstronautName(String astronautName){
this.astronautName = astronautName;
}

void getAstronautName(){
System.out.println(astronautName);
}

}
31 changes: 31 additions & 0 deletions second/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public class Main {
public static void main(String[] args) {
Spaceship sp1 = new Spaceship("Apollo","manned");
Spaceship sp2 = new Spaceship();

sp2.setSpaceshipName("Odyssey");
sp2.setSpaceshipHumanStatus("unmanned");

Astronaut as1 = new Astronaut("Hello");
Astronaut as2 = new Astronaut();

as2.setAstronautName("Bye");
//이름을 새로 입력하면 가장 최근에 입력된 이름으로 변경된다.
as2.setAstronautName("GoodBye");

//유인 탐사선 sp1 에 탐사대원을 탑승시킨다.
sp1.addAstronaut(as1);
sp1.addAstronaut(as2);
sp1.spaceshipPrintInformation();

//무인탐사선에는 탐사대원이 탑승 불가
sp2.addAstronaut(as1);
sp2.spaceshipPrintInformation();

//탐사대원이 탐사선에서 내린다.
sp1.removeAstronaut(as1);
//내린 탐사대원의 이름은 출력결과에서 사라진다.
sp1.spaceshipPrintInformation();

}
}
65 changes: 65 additions & 0 deletions second/src/Spaceship.java
Copy link
Member

Choose a reason for hiding this comment

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

무인과 유인에 따라서 변수가 필요없을 때도 있고 메서드 추가 조건문이 붙을 때도 있으니 상속을 사용해서 우주선 클래스를 만들고 무인선, 유인선 클래스를 각각 만들어서 우주선 클래스를 상속 받으면 좋을 것 같습니다!

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import java.util.ArrayList;
import java.util.List;

public class Spaceship {
private String spaceshipName; //탐사선이름
private String spaceshipHumanStatus; //탐사선이 무인인지 유인인지
Copy link
Member

Choose a reason for hiding this comment

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

Enum이라는 타입도 있으니 공부해 보시고 코드 개선해 보아도 좋을 것 같습니다!

private List<Astronaut> astronauts = new ArrayList<>(); //탑승한 탐사 대원 리스트

Spaceship(){}

Spaceship(String spaceshipName, String spaceshipHumanStatus){
this.spaceshipName = spaceshipName;
this.spaceshipHumanStatus = spaceshipHumanStatus;
}
Copy link
Member

Choose a reason for hiding this comment

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

무인 우주선일 때는 리스트를 생성할 필요가 없으니 생성자에서 조건문을 사용해서 리스트 생성 로직을 분리해도 좋을 것 같습니다!


//탐사선 이름을 입력받는 메소드
void setSpaceshipName(String spaceshipName){
this.spaceshipName = spaceshipName;
}

//탐사선이 유인인지 무인인지 입력받는 메소드
void setSpaceshipHumanStatus(String spaceshipHumanStatus){
this.spaceshipHumanStatus = spaceshipHumanStatus;
}

//탐사대원을 추가하는 메소드
//무인일 경우 탑승불가
void addAstronaut(Astronaut astronaut){
if (spaceshipHumanStatus.equals("manned")){
this.astronauts.add(astronaut);
}
else{
System.out.println("\n--------------------------------------\n");
System.out.println("선택하신 탐사선 "+spaceshipName+"은 무인 탐사선 입니다.");
System.out.println("무인 탐사선에는 탐사 대원이 탑승할 수 없습니다.");
System.out.println("\n--------------------------------------\n");
}
}

//탐사대원이 탐사선에서 내릴 수 있게 만드는 메소드
void removeAstronaut(Astronaut astronaut){
this.astronauts.remove(astronaut);
}

//탐사선의 정보를 출력하는 메소드
//탐서선 이름, 유인인지 무인인지, 탑승한 탐사 대원들의 이름 출력
void spaceshipPrintInformation(){
System.out.println("\n--------------------------------------\n");
System.out.println("탐사전 정보:");
System.out.println("\t- 이름: "+spaceshipName);
if (spaceshipHumanStatus.equals("manned")){
System.out.println("\t- 종류: 유인 탐사선");
System.out.println("\t- 탐사 대원: ");
for (Astronaut astronaut : astronauts){
System.out.print("\t\t- 탐사 대원: ");
astronaut.getAstronautName();
}
}
else{
System.out.println("\t- 종류: 무인 탐사선");
System.out.println("\t- 탐사 대원: 없음");
}
System.out.println("\n--------------------------------------\n");
}
}
11 changes: 11 additions & 0 deletions second/untitled.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>