From 0545fb42039ee21d523715ef2301f68c78f4e52a Mon Sep 17 00:00:00 2001 From: bit Date: Fri, 28 Dec 2018 17:14:12 +0900 Subject: [PATCH] end --- .classpath | 12 +++++----- src/prob1/Member.java | 22 ++++++++++++++++++ src/prob2/Goods.java | 34 +++++++++++++++++++++++++++ src/prob2/GoodsApp.java | 19 ++++++++++++++- src/prob3/CurrencyConverter.java | 15 ++++++++++++ src/prob4/StringUtil.java | 4 ++++ src/prob5/Account.java | 29 +++++++++++++++++++++++ src/prob6/Add.java | 16 +++++++++++++ src/prob6/CalcApp.java | 40 +++++++++++++++++++++++++++++--- src/prob6/Div.java | 16 +++++++++++++ src/prob6/Mul.java | 16 +++++++++++++ src/prob6/Sub.java | 15 ++++++++++++ 12 files changed, 228 insertions(+), 10 deletions(-) create mode 100644 src/prob6/Add.java create mode 100644 src/prob6/Div.java create mode 100644 src/prob6/Mul.java create mode 100644 src/prob6/Sub.java diff --git a/.classpath b/.classpath index 51a8bba..46bbddf 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - - - - - - + + + + + + diff --git a/src/prob1/Member.java b/src/prob1/Member.java index a53fede..b49286d 100644 --- a/src/prob1/Member.java +++ b/src/prob1/Member.java @@ -1,4 +1,26 @@ package prob1; public class Member { + private String id; + private String name; + private int point; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public int getPoint() { + return point; + } + public void setPoint(int point) { + this.point = point; + } + } diff --git a/src/prob2/Goods.java b/src/prob2/Goods.java index ad87ad4..1aa141e 100644 --- a/src/prob2/Goods.java +++ b/src/prob2/Goods.java @@ -2,4 +2,38 @@ public class Goods { + private String name; + private String price; + private String num; + + + public Goods(String name, String price, String num) { + this.name = name; + this.price = price; + this.num = num; + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getPrice() { + return price; + } + public void setPrice(String price) { + this.price = price; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + + public void show() { + System.out.println(name+"(가격:"+price+"원)이 "+num+"개 입고 되었습니다."); + } + } diff --git a/src/prob2/GoodsApp.java b/src/prob2/GoodsApp.java index c084690..797ac11 100644 --- a/src/prob2/GoodsApp.java +++ b/src/prob2/GoodsApp.java @@ -6,6 +6,23 @@ public class GoodsApp { private static final int COUNT_GOODS = 3; public static void main(String[] args) { - + Goods[] arrayGoods = new Goods[COUNT_GOODS]; + Scanner scanner = new Scanner( System.in ); + for(int i=0;i> " ); String expression = scanner.nextLine(); - - /* 코드를 완성 합니다 */ + if(expression.equals("quit")) + break; + String[] s = expression.split(" "); + + + int a = Integer.parseInt(s[0]); + String t = s[1]; + int b = Integer.parseInt(s[2]); + if(t.equals("+")) + { + Add add = new Add(); + add.setValue(a, b); + System.out.println(add.calculate()); + } + else if(t.equals("-")) + { + Sub add = new Sub(); + add.setValue(a, b); + System.out.println(add.calculate()); + } + else if(t.equals("*")) + { + Mul add = new Mul(); + add.setValue(a, b); + System.out.println(add.calculate()); + } + else if(t.equals("/")) + { + Div add = new Div(); + add.setValue(a, b); + System.out.println(add.calculate()); + } + + + } + } - } } diff --git a/src/prob6/Div.java b/src/prob6/Div.java new file mode 100644 index 0000000..fdde2cb --- /dev/null +++ b/src/prob6/Div.java @@ -0,0 +1,16 @@ +package prob6; + +public class Div { + + int a; + int b; + + void setValue(int a, int b) { + this.a = a; + this.b = b; + } + + int calculate(){ + return a / b; + } +} diff --git a/src/prob6/Mul.java b/src/prob6/Mul.java new file mode 100644 index 0000000..6f84e5a --- /dev/null +++ b/src/prob6/Mul.java @@ -0,0 +1,16 @@ +package prob6; + +public class Mul { + + int a; + int b; + + void setValue(int a, int b) { + this.a = a; + this.b = b; + } + + int calculate(){ + return a * b; + } +} diff --git a/src/prob6/Sub.java b/src/prob6/Sub.java new file mode 100644 index 0000000..1f320cf --- /dev/null +++ b/src/prob6/Sub.java @@ -0,0 +1,15 @@ +package prob6; + +public class Sub { + int a; + int b; + + void setValue(int a, int b) { + this.a = a; + this.b = b; + } + + int calculate(){ + return a - b; + } +}