Skip to content

Commit

Permalink
sec 2 - example2
Browse files Browse the repository at this point in the history
  • Loading branch information
hongjuzzang committed Jul 15, 2020
1 parent 54e3060 commit 4940c0d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 02_Adapter/src/example/AdapterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

public class AdapterImpl implements Adapter {

// 인터페이스를 이용해서 타입을 변경해서 사용하고 다시 원하는 타입으로 변경
@Override
public Float twiceOf(Float f) {
// TODO Auto-generated method stub
return (float) Math.twoTime(f.doubleValue());
return Math.doubled(f.doubleValue()).floatValue();
}

@Override
public Float halfOf(Float f) {
// TODO Auto-generated method stub
System.out.println("절반 함수 호출");
return (float) Math.half(f.doubleValue());
}

Expand Down
4 changes: 4 additions & 0 deletions 02_Adapter/src/example/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public static void main(String[] args) {

System.out.println(adapter.twiceOf(100f));
System.out.println(adapter.halfOf(88f));
System.out.println(adapter.halfOf(48f));
System.out.println(adapter.halfOf(28f));
System.out.println(adapter.halfOf(38f));
System.out.println(adapter.halfOf(18f));
}

}

0 comments on commit 4940c0d

Please sign in to comment.