import java.util.*;
abstract class TV{ //추상클래스 - 객체를 생성할수 없다. 틀 형태
private int size;
public TV(int size) {
this.size=size;
}
protected int getSize() {
return size;
}
abstract String view(); //추상메소드
}
class ColorTV extends TV{
private int Color;
public ColorTV(int size,int Color) {
super(size);
this.Color=Color;
}
protected int getColor()
{
return Color;
}
public void printProperty()
{
System.out.println(getSize()+"인치 "+getColor()+"컬러");
}
}
class IPTV extends ColorTV{
String ip;
public IPTV(String ip,int Color,int size)
{
super(size,Color);
this.ip=ip;
}
protected String getip()
{
return ip;
}
public void printProperty() // overriding (덮어쓰기)
{
System.out.print("나의 IPTV는 "+ip+" 주소의 ");
super.printProperty();
}
}
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
IPTV iptv=new IPTV("192.1.1.2",32,2048);
iptv.printProperty();
TV tv = new TV();
}
}
*/
/*
import java.util.*;
class Converter{
private int won;
protected Converter(int won)
{
this.won=won;
}
protected int getWon()
{
return won;
}
}
class Wond2Dollar extends Converter{
double dollar;
protected Wond2Dollar(int won,int d) {
super(won);
dollar=won/d;
}
public void run()
{
System.out.print("변환결과: "+dollar+"달러입니다");
}
}
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int w;
System.out.print("원을 입력하세요>>");
w=sc.nextInt();
Wond2Dollar toDollar =new Wond2Dollar(w,1200);
toDollar.run();
}
}
*/
/*
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 Won2Dollar extends Converter{
protected Won2Dollar(int w)
{
this.ratio=w;
}
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) {
Won2Dollar toDollar=new Won2Dollar(1200);
toDollar.run();
}
}
*/
/*
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{
protected Km2Mile(double w)
{
this.ratio=w;
}
protected double convert(double src) {
return src/ratio;
}
protected String getSrcString() {
return "Km";
}
protected String getDestString() {
return "mile";
}
}
public class Main{
public static void main(String[] args) {
Km2Mile toMile=new Km2Mile(1.6);
toMile.run();
}
}
*/
/*
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 ColorPoint extends Point{
String color;
protected ColorPoint(int x,int y,String color) {
super(x,y);
this.color=color;
}
protected void setXY(int x,int y)
{
move(x,y);
}
protected void setColor(String color)
{
this.color=color;
}
public String toString()
{
return color+"색의 "+"("+getX()+","+getY()+")의 점";
}
}
public 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.*;
class Point{
private int x=0,y=0;
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;
ColorPoint() {
this(0,0);
}
ColorPoint(int x,int y) {
super(x,y);
color="BLACK";
}
void setXY(int x,int y)
{
move(x,y);
}
void setColor(String color)
{
this.color=color;
}
public String toString()
{
return color+"색의 "+"("+getX()+","+getY()+")의 점";
}
}
public class Main{
public static void main(String[] args) {
ColorPoint zeroPoint = new ColorPoint();
System.out.println(zeroPoint.toString()+"입니다.");
ColorPoint cp = new ColorPoint(10,10);
cp.setXY(5,5);
cp.setColor("Red");
System.out.println(cp.toString()+"입니다.");
}
}
*/
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{
int z;
Point3D(int x,int y,int z)
{
super(x,y);
this.z=z;
}
protected void MoveUp()
{
z++;
}
protected void MoveDown()
{
z--;
}
protected void move(int x,int y,int z)
{
move(x,y);
this.z=z;
}
public String toString()
{
return "("+getX()+","+getY()+","+z+")의 점";
}
}
public class Main{
public static void main(String[] args) {
Point3D p=new Point3D(1,2,3);
System.out.println(p.toString()+"입니다.");
p.MoveUp();
System.out.println(p.toString()+"입니다.");
p.MoveDown();
p.move(10,10);
System.out.println(p.toString()+"입니다.");
p.move(100,200,300);
System.out.println(p.toString()+"입니다.");
}
}