-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fd6a65
commit 54e3060
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |