diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..68586da Binary files /dev/null and b/.DS_Store differ diff --git a/First/.idea/.gitignore b/First/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/First/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/First/.idea/jpa-buddy.xml b/First/.idea/jpa-buddy.xml new file mode 100644 index 0000000..966d5f5 --- /dev/null +++ b/First/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/First/.idea/misc.xml b/First/.idea/misc.xml new file mode 100644 index 0000000..3950286 --- /dev/null +++ b/First/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/First/.idea/modules.xml b/First/.idea/modules.xml new file mode 100644 index 0000000..2979964 --- /dev/null +++ b/First/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/First/.idea/uiDesigner.xml b/First/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/First/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/First/.idea/vcs.xml b/First/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/First/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/First/First.iml b/First/First.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/First/First.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/First/src/Animal.java b/First/src/Animal.java new file mode 100644 index 0000000..df43d96 --- /dev/null +++ b/First/src/Animal.java @@ -0,0 +1,13 @@ +public class Animal { + private String species; + private String name; + private int age; + + public void speak() { + System.out.println("동물이 소리를 냅니다."); + } + + public void drink() { + System.out.println("동물이 물을 마십니다."); + } +} diff --git a/First/src/Calculator.java b/First/src/Calculator.java new file mode 100644 index 0000000..13fcc52 --- /dev/null +++ b/First/src/Calculator.java @@ -0,0 +1,10 @@ +public class Calculator { + Character operator; + public int add(int a, int b) { + return a + b; + } + public double add(double a, double b) { + return a + b; + } + //여기서는 리턴 타입이 다르기때문에 오버로딩이다! +} \ No newline at end of file diff --git a/First/src/Car.java b/First/src/Car.java new file mode 100644 index 0000000..f338fe4 --- /dev/null +++ b/First/src/Car.java @@ -0,0 +1,4 @@ +public interface Car { + public abstract void turnOn(); + public abstract void turnOff(); +} diff --git a/First/src/ConvenienceStore.java b/First/src/ConvenienceStore.java new file mode 100644 index 0000000..90a1c18 --- /dev/null +++ b/First/src/ConvenienceStore.java @@ -0,0 +1,41 @@ +public class ConvenienceStore { + + String brand; + String address; + + int staffCount; + int visitorCount; + + public ConvenienceStore(String brand,String address,int staffCount,int visiotrCount){ + this.brand=brand; + this.address=address; + this.staffCount=staffCount; + this.visitorCount=visiotrCount; + } + public void addStaffCount() { + staffCount++; + } + + public int getStaffCount() { + return staffCount; + } + + public void addVisitorCount() { + visitorCount++; + } + + public void initVisitorCount() { + visitorCount = 0; + } + + public int getVisitorCount() { + return visitorCount; + } + + public void printConvenienceStoreInfo() { + System.out.println("편의점 브랜드: " + brand); + System.out.println("편의점 주소: " + address); + System.out.println("편의점 직원 수: " + staffCount); + System.out.println("편의점 방문자 수: " + visitorCount); + } +} diff --git a/First/src/Dog.java b/First/src/Dog.java new file mode 100644 index 0000000..6658cd4 --- /dev/null +++ b/First/src/Dog.java @@ -0,0 +1,11 @@ +public class Dog extends Animal { + private String gender; + public void walk() { + System.out.println("강아지가 산책을 합니다."); + } + //오버라이딩은 부모 클래스의 동작을 재정의! + @Override + public void speak() { + System.out.println("월월"); + } +} \ No newline at end of file diff --git a/First/src/GenericTest.java b/First/src/GenericTest.java new file mode 100644 index 0000000..d0af27e --- /dev/null +++ b/First/src/GenericTest.java @@ -0,0 +1,19 @@ +class GenericClass { + T type; + E element; +} +class GenericMethod { + public T genericMethod(T type) { + return type; + } +} +public class GenericTest { + public static void main(String[] args) { + GenericClass genericClass = new GenericClass(); + GenericMethod genericMethod = new GenericMethod(); + + String hello = genericMethod.genericMethod("Hello"); + System.out.println(hello); + } + +} \ No newline at end of file diff --git a/First/src/HardMisson/Bank.java b/First/src/HardMisson/Bank.java new file mode 100644 index 0000000..13d38d3 --- /dev/null +++ b/First/src/HardMisson/Bank.java @@ -0,0 +1,11 @@ +package HardMisson; + +public interface Bank { + public abstract void deposit(int money); + + + + public abstract void withdraw(int money); + public abstract void checkMoney(); + +} diff --git a/First/src/HardMisson/BankUser.java b/First/src/HardMisson/BankUser.java new file mode 100644 index 0000000..fa87ad0 --- /dev/null +++ b/First/src/HardMisson/BankUser.java @@ -0,0 +1,14 @@ +package HardMisson; + +public class BankUser { + public static void main(String[] args) { + WooriBank wooriBank=new WooriBank(0,"010-1234-5678","www.wooribank.com"); + //인스턴스 생성,힙에 할당되게 됩니당 + wooriBank.deposit(1000); + wooriBank.checkMoney(); + wooriBank.withdraw(2000);// 에러 처리 발생~ + } + + + +} diff --git a/First/src/HardMisson/WooriBank.java b/First/src/HardMisson/WooriBank.java new file mode 100644 index 0000000..8f58711 --- /dev/null +++ b/First/src/HardMisson/WooriBank.java @@ -0,0 +1,37 @@ +package HardMisson; + +import HardMisson.Bank; + +public class WooriBank implements Bank { + + int currentMoney; + String telephone; + String webUrl; + + public WooriBank(int currentMoney,String telephone,String webUrl){ + this.currentMoney=currentMoney; + this.telephone=telephone; + this.webUrl=webUrl; + System.out.println("은행 생성완료!"); + } + @Override + public void deposit(int money) { + this.currentMoney=this.currentMoney+money; + System.out.println(money+"만큼 입금되었습니다!"); + } + + @Override + public void withdraw(int money){ + if(this.currentMoney-money<0){ + System.out.println("잔고가 부족해 출금할 수 없습니다!"); + } + else{ + this.currentMoney=this.currentMoney-money; + System.out.println(money+"만큼 출금되었습니다!");} + }; + @Override + public void checkMoney(){ + System.out.println("현재 은행에 남은 잔고는 "+this.currentMoney+"입니다!"); + }; + +} diff --git a/First/src/Main.java b/First/src/Main.java new file mode 100644 index 0000000..f8c5863 --- /dev/null +++ b/First/src/Main.java @@ -0,0 +1,23 @@ +public class Main { + public static void main(String[] args) { + + Animal animal=new Animal(); + animal.speak(); + + ConvenienceStore firstGS = new ConvenienceStore("GS 25", "지구 어딘가", 8, 0); + + firstGS.addStaffCount(); + firstGS.addVisitorCount(); + + firstGS.printConvenienceStoreInfo(); + + Calculator calculator = new Calculator(); + + int intResult = calculator.add(1, 10); + double doubleResult = calculator.add(1, 10); + + System.out.println(intResult); + System.out.println(doubleResult); + } +} + diff --git a/First/src/Person.java b/First/src/Person.java new file mode 100644 index 0000000..d06366c --- /dev/null +++ b/First/src/Person.java @@ -0,0 +1,12 @@ +public abstract class Person { + private String gender; + + public abstract void walk(); +} + +class Student extends Person { + @Override + public void walk() { + System.out.println("학교로 걸어갈게요."); + } +} \ No newline at end of file diff --git a/First/src/SportsCar.java b/First/src/SportsCar.java new file mode 100644 index 0000000..77ff89c --- /dev/null +++ b/First/src/SportsCar.java @@ -0,0 +1,10 @@ +public class SportsCar implements Car{ + @Override + public void turnOn() { + System.out.println("스포츠카 시동 부릉"); + } + @Override + public void turnOff() { + System.out.println("스포츠카 시동 끄기"); + } +}