2022.04.10.
import java.util.*;
/*class Point {
private int x,y;
public Point(int x, int y){
this.x = x;
this.y = y;
}
public int getX() { return x; }
public int getY() { return y; }
protected void move(int x , int y) { this.x = x; this.y = y;}
}
/*class Point3D extends Point {
private int z;
public Point3D(int x, int y, int z) {
super(x,y);
this.z = z;
}
public void moveup() {
z--;
}
public void movedown( ) {
z++;
}
public void move(int x,int y, int z) {
move(x,y);
this.z = z;-
}
public String toString()
{
return "(" + getX() + "," + getY() +"," + z + ")의 점";
}
}
*/
/*
class Student extends Person{
void speak() {
System.out.println("저는 학생입니다.");
}
}
*/
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 Won2Dollor extends Converter{
public Won2Dollor(double ratio) {
this.ratio=ratio;
}
protected double convert(double src) {
return src/ratio;
}
protected String getSrcString() {
return "원";
}
protected String getDestString() {
return "달러";
}
}
public class Main {
public static void main(String[] args) {
//Person p = new Person(); //추상클래스 객ㅊㅔ 만들 수 없다.
Won2Dollor toDollor = new Won2Dollor(1200);
toDollor.run();
}
}



