-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
[WEEK1] 기본 과제 & 도전 과제 제출 #1
- Loading branch information
There are no files selected for viewing
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class Main { | ||
public static void main(String[] args) { | ||
System.out.println("Hello world!"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
abstract class Food{ // 부모 클래스 추상화 | ||
|
||
abstract public void eat(String name); // 선언은 되어 있으나 구현은 하지 않은 상태 | ||
abstract public void hate(String food); | ||
|
||
abstract public void count(int food); | ||
|
||
} | ||
class Eggplant extends Food { // 추상클래스 Food를 상속받은 자손 클래스 | ||
@Override | ||
public void eat(String name) { // 오버라이드 | ||
System.out.println(name + "이 음식을 먹습니다."); | ||
} | ||
@Override | ||
public void hate(String food){ | ||
System.out.println("으! 아차! 이 음식은" + food + "였네요." ); | ||
} | ||
@Override | ||
|
||
public void count(int food){ | ||
System.out.println("맛있는건줄 알고 " + food + "개나 먹었어요."); | ||
} | ||
} | ||
|
||
|
||
public class abstractMethod { | ||
public static void main(String[] args) { | ||
Eggplant eggplant = new Eggplant(); // 인스턴스 | ||
eggplant.eat("유진"); | ||
eggplant.hate("가지"); | ||
eggplant.count(3); // 오버 로딩 같은 food 지만 다른 타입으로 동작 | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Test<T>{ // 제네릭 클래스 생성 | ||
private T value; | ||
|
||
public T get() { | ||
return value; | ||
} | ||
public void set(T value) { | ||
this.value = value; | ||
} | ||
|
||
} | ||
|
||
public class generic { | ||
|
||
public static void main(String[] args) { | ||
Test<String> StringGeneric = new Test<String>(); // 제네릭 인스턴스 타입을 다르게 생성 | ||
Test<Integer> IntGeneric = new Test<Integer>(); | ||
|
||
StringGeneric.set("어려운것 같아요"); | ||
String str = StringGeneric.get(); // String 형식 | ||
|
||
IntGeneric.set(20); | ||
int val = IntGeneric.get(); // Int 형식 | ||
|
||
System.out.println("제네릭은 " + str); | ||
System.out.println("한 이정도..." + val); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
interface Animal { // Animal 인터페이스 | ||
public abstract void talk(); | ||
|
||
} | ||
|
||
interface Feed { // Food 인터페이스 | ||
public abstract void food(String food); | ||
public abstract void cnt(int cnt); | ||
} | ||
|
||
class Hamster implements Animal,Feed { // 인터페이스 다중 상속 가능 | ||
public String talk = "쥑쥑"; | ||
|
||
@Override // 인터페이스의 경우 모든 메서드를 무조건 호출 | ||
public void talk() { | ||
System.out.println("햄스터는 " + this.talk); | ||
} | ||
@Override | ||
public void food(String food) { | ||
System.out.println("나는 " + food + "를 좋아해"); | ||
} | ||
@Override | ||
public void cnt(int cnt) { | ||
System.out.println("오늘 " + cnt + "개 먹었어.쥑쥑"); | ||
} | ||
} | ||
public class interfaceJava { | ||
public static void main(String[] args) { | ||
Hamster hamster = new Hamster(); | ||
hamster.talk(); | ||
hamster.food("해바라기씨"); | ||
hamster.cnt(5); | ||
} | ||
} |
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> |