import java.util.*;
abstract class Converter{
abstract protected double convert(double src);
abstract protected String getSrcString();
abstract protected String getDestString();
protected double ratio;
public void run() {
Scanner sc = new Scanner(System.in);
System.out.println(getSrcString()+"을"+ getDestString()+"로 바꿉니다.");
System.out.print(getSrcString()+"을 입력하시오>>>>>>> ");
double val = sc.nextDouble();
double res = convert(val);
System.out.println("변환결과"+res+ getDestString()+"입니다");
sc.close();
}
}
class Km2Mile extends Converter{
Km2Mile(double m){
ratio = m;
}
protected double convert(double src) {
return src/ratio;
}
protected String getSrcString() {
return "Km";
}
protected String getDestString() {
return "mile";
}
}
class Main{
public static void main(String[] args) {
Km2Mile toMile = new Km2Mile(1.6);
toMile.run();
}
}
class Won2Dollar extends Converter{
Won2Dollar(int r){
ratio = r;
}
protected double convert(double src) {
return src/ratio;
}
protected String getSrcString() {
return "원";
}
protected String getDestString() {
return "달러";
}
}
class Main{
public static void main(String[] args) {
Won2Dollar toDollar = new Won2Dollar(1200);
toDollar.run();
}
}
interface Converter{
public static double ratio=1200; //상수 필드
abstract double convert(double src); //추상메소드
abstract String getSrcString();//추상메소드
abstract String getDestString();//추상메소드
}
interface Converter2{
abstract double convert(double src); //추상메소드
abstract String getSrcString();//추상메소드
abstract String getDestString();//추상메소드
}
class Won2Dollar imp lements Converter, Converter2{
Won2Dollar(double r){
}
public double convert(double src) {
return src/ratio;
}
public String getSrcString() {
return "원";
}
public String getDestString() {
return "달러";
}
}
class Main{
public static void main(String[] args) {
Won2Dollar toDollar = new Won2Dollar(1200);
}
}
*/
interface PhoneInterface {
final int TIMEOUT = 10000;
void sendCall();
void receiveCall();
default void printLogo() {
System.out.println("** phone **");
}
}
interface MobilePhoneInterface extends PhoneInterface{
void sendSMS();
void receiveSMS();
}
interface MP3Interface {
public void play();
public void stop();
}
class PDA{
public int calculate(int x,int y) {
return x + y;
}
}
class SmartPhone extends PDA implements MobilePhoneInterface,MP3Interface{
public void sendCall() {
System.out.println("따르르르르르르르ㅡㄹㄹㅇ");
}
public void receiveCall() {
System.out.println("전화옴");
}
public void sendSMS() {
System.out.println("문자감");
}
public void receiveSMS() {
System.out.println("문자옴");
}
public void play() {
System.out.println("음악 연주 ㄱ");
}
public void stop() {
System.out.println("음악 멈");
}
public void schedule() {
System.out.println("일정관리");
}
}
public class Main{
public static void main(String[] args) {
SmartPhone phone = new SmartPhone();
phone.printLogo();
phone.sendCall();
phone.play();
System.out.println("3과 5를 더하면"+ phone.calculate(3, 5));
phone.schedule();
}
}