Skip to content

Commit

Permalink
sec 2 - example1
Browse files Browse the repository at this point in the history
  • Loading branch information
hongjuzzang committed Jul 15, 2020
1 parent 9fd6a65 commit 54e3060
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 02_Adapter/src/example/Adapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package example;

public interface Adapter {

// 원하는 기능
public Float twiceOf(Float f);

public Float halfOf(Float f);
}
18 changes: 18 additions & 0 deletions 02_Adapter/src/example/AdapterImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package example;

public class AdapterImpl implements Adapter {

@Override
public Float twiceOf(Float f) {
// TODO Auto-generated method stub
return (float) Math.twoTime(f.doubleValue());
}

@Override
public Float halfOf(Float f) {
// TODO Auto-generated method stub
return (float) Math.half(f.doubleValue());
}


}
14 changes: 14 additions & 0 deletions 02_Adapter/src/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package example;

public class Main {

public static void main(String[] args) {
// TODO Auto-generated method stub

Adapter adapter = new AdapterImpl();

System.out.println(adapter.twiceOf(100f));
System.out.println(adapter.halfOf(88f));
}

}
21 changes: 21 additions & 0 deletions 02_Adapter/src/example/Math.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package example;

public class Math {

// 이미 구현되어 있는 클래스(요구사항)

// 두배
public static double twoTime(double num) {
return num * 2;
}

// 절반
public static double half(double num) {
return num / 2;
}

// 강화된 알고리즘
public static Double doubled(Double d) {
return d * 2;
}
}

0 comments on commit 54e3060

Please sign in to comment.