Skip to content
Open
Show file tree
Hide file tree
Changes from all 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.
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

4 changes: 4 additions & 0 deletions .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 .idea/modules.xml

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

9 changes: 9 additions & 0 deletions .idea/space.iml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

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.

46 changes: 46 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.
11 changes: 11 additions & 0 deletions second/second.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>
7 changes: 7 additions & 0 deletions second/src/Astronaut.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class Astronaut extends Information{

Astronaut (String informationName){
super(informationName);
}

}
15 changes: 15 additions & 0 deletions second/src/Information.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Information {
String informationName;

Information (String informationName){
this.informationName=informationName;
}

void getName(){
System.out.println(informationName);
}

void setName(String informationName){
this.informationName = informationName;
}
}
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) {
Spaceshipmanned sp1 = new Spaceshipmanned("Apollo");
Spaceshipunmanned sp2 = new Spaceshipunmanned("Odyssey");

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

//탐사선 이름 수정하기
sp1.setName("apollo");
sp2.setName("odyssey");

//탐사 대원 이름 수정하기
as1.setName("hello");
as2.setName("bye");

//탐사 대원 탐사선에 탑승
sp1.addAstronaut(as1);
sp1.addAstronaut(as2);

//탐사선 정보 출력
sp1.spaceshipPrintInformation();
sp2.spaceshipPrintInformation();

//탐사 대원 탐사선에서 내리기
sp1.removeAstronaut(as1);

//탐사 대원이 탐사선에서 내리면 탐사 대원 목록에서 사라진다.
sp1.spaceshipPrintInformation();
}
}
35 changes: 35 additions & 0 deletions second/src/Spaceshipmanned.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.ArrayList;
import java.util.List;

public class Spaceshipmanned extends Information {
private List<Astronaut> astronauts = new ArrayList<>(); //탑승한 탐사 대원 리스트

Spaceshipmanned(String informationName){
super(informationName);
}

//탐사대원을 추가하는 메소드
void addAstronaut(Astronaut astronaut){
this.astronauts.add(astronaut);
}

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

//탐사선의 정보를 출력하는 메소드
//탐서선 이름, 유인인지 무인인지, 탑승한 탐사 대원들의 이름 출력
void spaceshipPrintInformation(){
System.out.println("\n--------------------------------------\n");
System.out.println("탐사선 정보:");
System.out.println("\t- 이름: "+informationName);
System.out.println("\t- 종류: 유인 탐사선");
System.out.println("\t- 탐사 대원: ");
for (Astronaut astronaut : astronauts) {
System.out.print("\t\t- ");
astronaut.getName();
}
System.out.println("\n--------------------------------------\n");
}
}
17 changes: 17 additions & 0 deletions second/src/Spaceshipunmanned.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class Spaceshipunmanned extends Information {

Spaceshipunmanned(String informationName){
super(informationName);
}

//탐사선의 정보를 출력하는 메소드
//탐서선 이름, 유인인지 무인인지, 탑승한 탐사 대원들의 이름 출력
void spaceshipPrintInformation(){
System.out.println("\n--------------------------------------\n");
System.out.println("탐사선 정보:");
System.out.println("\t- 이름: "+informationName);
System.out.println("\t- 종류: 무인 탐사선");
System.out.println("\t- 탐사 대원: 없음");
System.out.println("\n--------------------------------------\n");
}
}