diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5f58a24 Binary files /dev/null and b/.DS_Store differ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..c3f502a --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 디폴트 무시된 파일 +/shelf/ +/workspace.xml +# 에디터 기반 HTTP 클라이언트 요청 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c1c2a99 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d4c1c8d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/space.iml b/.idea/space.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/space.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/second/.DS_Store b/second/.DS_Store new file mode 100644 index 0000000..6cc980c Binary files /dev/null and b/second/.DS_Store differ diff --git a/second/.gitignore b/second/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/second/.gitignore @@ -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 \ No newline at end of file diff --git a/second/.idea/.gitignore b/second/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/second/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/second/.idea/misc.xml b/second/.idea/misc.xml new file mode 100644 index 0000000..e6be3f1 --- /dev/null +++ b/second/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/second/.idea/modules.xml b/second/.idea/modules.xml new file mode 100644 index 0000000..a2a1111 --- /dev/null +++ b/second/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/second/.idea/workspace.xml b/second/.idea/workspace.xml new file mode 100644 index 0000000..eaef01a --- /dev/null +++ b/second/.idea/workspace.xml @@ -0,0 +1,46 @@ + + + + + + + + + { + "customColor": "", + "associatedIndex": 6 +} + + + + + + + + + 1723003773300 + + + + \ No newline at end of file diff --git a/second/out/production/second/Astronaut.class b/second/out/production/second/Astronaut.class new file mode 100644 index 0000000..5ca4cc3 Binary files /dev/null and b/second/out/production/second/Astronaut.class differ diff --git a/second/out/production/second/Main.class b/second/out/production/second/Main.class new file mode 100644 index 0000000..b5a6ab3 Binary files /dev/null and b/second/out/production/second/Main.class differ diff --git a/second/second.iml b/second/second.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/second/second.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/second/src/Astronaut.java b/second/src/Astronaut.java new file mode 100644 index 0000000..a35b30d --- /dev/null +++ b/second/src/Astronaut.java @@ -0,0 +1,7 @@ +public class Astronaut extends Information{ + + Astronaut (String informationName){ + super(informationName); + } + +} \ No newline at end of file diff --git a/second/src/Information.java b/second/src/Information.java new file mode 100644 index 0000000..859c37b --- /dev/null +++ b/second/src/Information.java @@ -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; + } +} \ No newline at end of file diff --git a/second/src/Main.java b/second/src/Main.java new file mode 100644 index 0000000..02f140c --- /dev/null +++ b/second/src/Main.java @@ -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(); + } +} \ No newline at end of file diff --git a/second/src/Spaceshipmanned.java b/second/src/Spaceshipmanned.java new file mode 100644 index 0000000..549157d --- /dev/null +++ b/second/src/Spaceshipmanned.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; + +public class Spaceshipmanned extends Information { + private List 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"); + } +} diff --git a/second/src/Spaceshipunmanned.java b/second/src/Spaceshipunmanned.java new file mode 100644 index 0000000..dd60678 --- /dev/null +++ b/second/src/Spaceshipunmanned.java @@ -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"); + } +} \ No newline at end of file