/*
class TV {
private int size;
public TV(int size) {
this.size = size;
}
protected int getSize() {
return size;
}
}
class ColorTV extends TV
{
int color;
public ColorTV(int size, int color)
{
super(size);
this.color = color;
}
}
class IPTV extends ColorTV
{
String iptv;
public IPTV(String iptv,int size, int color)
{
super(size, color);
this.iptv=iptv;
}
public void printProperty()
{
System.out.print("나의 IPTV는 " + iptv + "주소의 " + getSize() + "인치 " + color + "컬러");
}
}
class Main {
public static void main(String[] args) {
IPTV ipTV = new IPTV("192.1.2", 32, 2048);
ipTV.printProperty();
}
}
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 ColorPoint extends Point
{
String color;
public ColorPoint(int x,int y,String color)
{
super(x,y);
this.color=color;
}
public void setColor(String color) {
this.color=color;
}
public void setXY(int x,int y)
{
move(x,y);
}
public String toString()
{
return color+"색의 ("+getX()+","+getY()+")의 점";
}
}
class Main
{
public static void main(String[] args) {
ColorPoint cp=new ColorPoint(5,5,"YELLOW");
cp.setXY(10,20);
cp.setColor("RED");
String str=cp.toString();
System.out.println(str+"입니다.");
}
}*/
import java.util.Scanner;
abstract class Converter{
abstract protected double convert(double src);//추상 메솓ㅡ
abstract protected String getSrcString();//추상 메소드
abstract protected String getDestString();//추상 메소드
protected double ratio;//비율
public void run() {
Scanner scanner=new Scanner(System.in);
System.out.println(getSrcString()+"을"+getDestString()+"로 바꿉니다.");
System.out.print(getSrcString()+"을 입력하세요>>");
double val=scanner.nextDouble();
double res=convert(val);
System.out.println("변환결과: "+res+getDestString()+"입니다");
scanner.close();
}
}
class Won2Dollar extends Converter
{
public Won2Dollar(double res)
{
this.ratio=res;
}
protected double convert(double src) {
return src/ratio;
}
protected String getSrcString() {
return "원";
}
protected String getDestString() {
// TODO Auto-generated method stub
return "달러";
}
}
class Main{
public static void main(String[] args) {
Won2Dollar toDollar=new Won2Dollar(1200);
toDollar.run();
}
}