JAVA高手帮小弟个忙~感激

来源:百度知道 编辑:UC知道 时间:2024/07/14 19:41:36
1。编写1个类来描述坐标点的状态信息以及每个状态信息的设置和读取方法。
2。为第1题所编写的类添加两个构造方法,要求如下:
第一个构造方法为默认构造方法,将坐标点初始化到(0,0)位置。
第二个构造方法带有两个参数,分别初始化横坐标和纵坐标。
3。编写一个类,该类描述了一个具有权值的坐标点,要求如下:
该类必须继承第2题所编写的类;
该类必须具有一个带三个参数的构造方法,分别初始化横坐标,纵坐标和点的权值,并且必须使用父类的构造方法来初始化横坐标和纵坐标。
能告诉我你们给的是第几题的解答吗?

// Point.java
public class Point
{
private int x,y;
public Point()
{
x=0;
y=0;
}
public Point(int x,int y)
{
this.x=x;
this.y=y;
}

public int getX()
{
return x;
}
public void setX(int x)
{
this.x=x;
}
public int getY()
{
return y;
}
public void setY(int y)
{
this.y=y;
}
}

// PointWithWeight.java
public class PointWithWeight extends Point
{
private int weight;
public PointWithWeight(int x,int y,int weight)
{
super(x,y);
this.weight=weight;
}

public int getWeight()
{
return weight;
}
public void setWeight(int weight)
{
this.weight=weight;
}
}

//////////Test.java

public class Test1{
String x="";
String y="";
public Tes