Skip to content

Commit

Permalink
[WEEK1] 기본 과제 & 도전 과제
Browse files Browse the repository at this point in the history
[WEEK1] 기본 과제 & 도전 과제 제출

#1
  • Loading branch information
jinchiim committed Apr 14, 2023
1 parent 69788ac commit 50c5f74
Show file tree
Hide file tree
Showing 18 changed files with 453 additions and 0 deletions.
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("유진");
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>();

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

0 comments on commit 50c5f74

Please sign in to comment.