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

[기본과제/심화과제] 1주차 자바 객체지향 개념/ 은행 구현하기 #1

Open
wants to merge 16 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
Binary file added .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions First/.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 First/.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 First/.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 First/.idea/modules.xml

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

124 changes: 124 additions & 0 deletions First/.idea/uiDesigner.xml

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

6 changes: 6 additions & 0 deletions First/.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 First/First.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>
13 changes: 13 additions & 0 deletions First/src/Animal.java
Original file line number Diff line number Diff line change
@@ -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("동물이 물을 마십니다.");
}
}
10 changes: 10 additions & 0 deletions First/src/Calculator.java
Original file line number Diff line number Diff line change
@@ -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;
}
//여기서는 리턴 타입이 다르기때문에 오버로딩이다!
}
4 changes: 4 additions & 0 deletions First/src/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public interface Car {
public abstract void turnOn();
public abstract void turnOff();
}
41 changes: 41 additions & 0 deletions First/src/ConvenienceStore.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
11 changes: 11 additions & 0 deletions First/src/Dog.java
Original file line number Diff line number Diff line change
@@ -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("월월");
}
}
19 changes: 19 additions & 0 deletions First/src/GenericTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class GenericClass <T, E> {
T type;
E element;
}
class GenericMethod {
public <T> T genericMethod(T type) {
return type;
}
}
public class GenericTest {
public static void main(String[] args) {
GenericClass<Integer, String> genericClass = new GenericClass<Integer, String>();
GenericMethod genericMethod = new GenericMethod();

String hello = genericMethod.genericMethod("Hello");
System.out.println(hello);
}

}
11 changes: 11 additions & 0 deletions First/src/HardMisson/Bank.java
Original file line number Diff line number Diff line change
@@ -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();

}
Comment on lines +3 to +11
Copy link
Member

Choose a reason for hiding this comment

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

옹 은행을 인터페이스로 만들기 이렇게도 활용할 수 있군여👏

Copy link

Choose a reason for hiding this comment

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

ㅇㅈㅇㅈ그생각은못함

14 changes: 14 additions & 0 deletions First/src/HardMisson/BankUser.java
Original file line number Diff line number Diff line change
@@ -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);// 에러 처리 발생~
Copy link

Choose a reason for hiding this comment

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

굿굿!!

}



}
37 changes: 37 additions & 0 deletions First/src/HardMisson/WooriBank.java
Original file line number Diff line number Diff line change
@@ -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("잔고가 부족해 출금할 수 없습니다!");
Copy link

Choose a reason for hiding this comment

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

ㅋ실생활에서 없으면 100억부자 가능ㅇ인데

}
else{
this.currentMoney=this.currentMoney-money;
System.out.println(money+"만큼 출금되었습니다!");}
};
@Override
public void checkMoney(){
System.out.println("현재 은행에 남은 잔고는 "+this.currentMoney+"입니다!");
};

}
23 changes: 23 additions & 0 deletions First/src/Main.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

12 changes: 12 additions & 0 deletions First/src/Person.java
Original file line number Diff line number Diff line change
@@ -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("학교로 걸어갈게요.");
}
}
Loading