//// 왜 action에 conver c를 집어넣는가?
package april4;
public class zclass4 {
public static void main(String[] args) {
action(moneyconvertor::convert);
action(moneyconvertor::instanceconvert);
}
public static void action(convertor con){
int result = con.conv(10000,'$');
System.out.println("변환된 돈 : $" + result);
}
}
class moneyconvertor{
public static int convert(int money, char c){
int convertmoney = 0;
switch(c){
case'$':
convertmoney = money/1300;
break;
case'\\':
convertmoney = money *1300;
break;
default:
convertmoney =-1;
break;
}
return convertmoney;
}
public static int instanceconvert(int money, char c){
int convertmoney = 0;
switch(c){
case'$':
convertmoney = money/1300;
break;
case'\\':
convertmoney = money *1300;
break;
default:
convertmoney =-1;
break;
}
return convertmoney;
}}
interface convertor{
int conv(int a, char c);
}
[람다함수] 곱하고 더하고 빼는걸 람다함수로 (0) | 2023.04.04 |
---|---|
[람다함수] 각종 문자 더하고 indexof 구하는 예제 (0) | 2023.04.04 |
[람다인터페이스] 소문자 대문자로 바꾸는거 (0) | 2023.04.04 |
[쓰레드 동기화] 책빌리기 (0) | 2023.04.04 |
[쓰레드종료] interrupt로 (0) | 2023.04.03 |
댓글 영역