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

[WEEK1] 기본 과제 & 도전 과제 #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
29 changes: 29 additions & 0 deletions firstClass/basicAssignments/.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
6 changes: 6 additions & 0 deletions firstClass/basicAssignments/.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 firstClass/basicAssignments/.idea/modules.xml

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

4 changes: 4 additions & 0 deletions firstClass/basicAssignments/.idea/workspace.xml

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

11 changes: 11 additions & 0 deletions firstClass/basicAssignments/basicAssignments.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>
5 changes: 5 additions & 0 deletions firstClass/basicAssignments/src/Main.java
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!");
}
}
34 changes: 34 additions & 0 deletions firstClass/basicAssignments/src/abstractMethod.java
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("유진");

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋ 가지가 유진이를 먹는건가요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ가지한테 침식 당한....유진...

Copy link
Member

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ넘 귀염귀염 한데요 ~~

eggplant.hate("가지");
eggplant.count(3); // 오버 로딩 같은 food 지만 다른 타입으로 동작
}
}

29 changes: 29 additions & 0 deletions firstClass/basicAssignments/src/generic.java
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>();
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

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

제네릭 테스트를 어떻게 해야 할지 고민했었는데 이렇게 해보는 것도 너무 좋은 방법인 것 같아요!!


StringGeneric.set("어려운것 같아요");
String str = StringGeneric.get(); // String 형식

IntGeneric.set(20);
int val = IntGeneric.get(); // Int 형식

System.out.println("제네릭은 " + str);
System.out.println("한 이정도..." + val);
}

}
34 changes: 34 additions & 0 deletions firstClass/basicAssignments/src/interfaceJava.java
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);
}
}
29 changes: 29 additions & 0 deletions firstClass/moreAssignment/.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
8 changes: 8 additions & 0 deletions firstClass/moreAssignment/.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 firstClass/moreAssignment/.idea/jpa-buddy.xml

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

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

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

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

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

11 changes: 11 additions & 0 deletions firstClass/moreAssignment/moreAssignment.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>
Loading