早教吧作业答案频道 -->其他-->
各位计算机大神,求解java题目。1.编写Point类,描述平面坐标XY上的点。doublex,yPoint()Point(doublex,doubley)setPoint(doublex,doubley)getPointX()getPointY()----------------------------------------------编写Circ
题目详情
各位计算机大神,求解java题目。
1.编写Point类,描述平面坐标XY上的点。
double x,y
Point()
Point(double x,double y)
setPoint(double x,double y)
getPointX()
getPointY()
----------------------------------------------
编写Circle类,继承上述的Point类,描述平面坐标XY上的园。
double r
Circle()
Circle(Point p,double r)
setR(double r)
getCircumference()
getCircArea()
---------------------------------------------
编写主类TestCircle,计算园的周长和面积,并输出结果和圆心位置。
---------------------------------------------
2.定义抽象类Function,其中包含抽象方法doFunction()。
定义类Function11,描述一元一次方程,并重写抽象方法doFunction()。
定义类Function12,描述一元二次方程,并重写抽象方法doFunction()。
定义类Function21,描述二元一次方程,并重写抽象方法doFunction()。
--------------------------------------------------
编写主类TestFunction,求解上述三种方程,并输出结果。
------------------------------------------------------
3.将上述抽象类定义成接口,并完成同样的功能。
1.编写Point类,描述平面坐标XY上的点。
double x,y
Point()
Point(double x,double y)
setPoint(double x,double y)
getPointX()
getPointY()
----------------------------------------------
编写Circle类,继承上述的Point类,描述平面坐标XY上的园。
double r
Circle()
Circle(Point p,double r)
setR(double r)
getCircumference()
getCircArea()
---------------------------------------------
编写主类TestCircle,计算园的周长和面积,并输出结果和圆心位置。
---------------------------------------------
2.定义抽象类Function,其中包含抽象方法doFunction()。
定义类Function11,描述一元一次方程,并重写抽象方法doFunction()。
定义类Function12,描述一元二次方程,并重写抽象方法doFunction()。
定义类Function21,描述二元一次方程,并重写抽象方法doFunction()。
--------------------------------------------------
编写主类TestFunction,求解上述三种方程,并输出结果。
------------------------------------------------------
3.将上述抽象类定义成接口,并完成同样的功能。
▼优质解答
答案和解析
package Circle;
/**
* 定义点类
* @author Sontion
*
*/
public class Point {
//X坐标和y坐标
private double x;
private double y;
//重写构造方法
public Point(double x, double y) {
this.x = x;
this.y = y;
}
//定义get/set方法
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
package Circle;
/**
* 编写圆类
* @author Sontion
*
*/
public class Circle {
private double r;
private Point point;
public Circle(double r, Point point) {
super();
this.r = r;
this.point = point;
}
/**周长*/
public double getLength(Circle c){
double length=0.0;
double pi=3.14;
length=2*pi*c.getR();
return length;
}
/**面积*/
public double getArea (Circle c){
double length=0.0;
double pi=3.14;
length=pi*c.getR()*c.getR();
return length;
}
public double getR() {
return r;
}
public void setR(double r) {
this.r = r;
}
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
}
}
package Circle;
public class test {
public static void main(String[] args) {
Point po = new Point(1.0,1.0);
Circle c = new Circle(4.0,po);
double a = c.getLength(c);
double b = c.getArea(c);
System.out.println(a+","+b);
}
}
写了个,可能我没明白你的意思,算周长用x,y干嘛?
/**
* 定义点类
* @author Sontion
*
*/
public class Point {
//X坐标和y坐标
private double x;
private double y;
//重写构造方法
public Point(double x, double y) {
this.x = x;
this.y = y;
}
//定义get/set方法
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
package Circle;
/**
* 编写圆类
* @author Sontion
*
*/
public class Circle {
private double r;
private Point point;
public Circle(double r, Point point) {
super();
this.r = r;
this.point = point;
}
/**周长*/
public double getLength(Circle c){
double length=0.0;
double pi=3.14;
length=2*pi*c.getR();
return length;
}
/**面积*/
public double getArea (Circle c){
double length=0.0;
double pi=3.14;
length=pi*c.getR()*c.getR();
return length;
}
public double getR() {
return r;
}
public void setR(double r) {
this.r = r;
}
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
this.point = point;
}
}
package Circle;
public class test {
public static void main(String[] args) {
Point po = new Point(1.0,1.0);
Circle c = new Circle(4.0,po);
double a = c.getLength(c);
double b = c.getArea(c);
System.out.println(a+","+b);
}
}
写了个,可能我没明白你的意思,算周长用x,y干嘛?
看了 各位计算机大神,求解java...的网友还看了以下:
电子中的定律公式I=U/RU是以伏特为单位I是以A为单位那R是不是也欧姆为单位P=IU=I平方R= 2020-06-07 …
有二位数组a[n][m]对于指针问题*(*(a+i)+j)与a[i][j]为什么等价(i,j在n, 2020-06-12 …
C语言中二维数组a[i][j]中,a+i=*(a+i)=a[i]=&a[i]是怎么理解的.其中*( 2020-06-27 …
一直z=(2+i)(1+1/i){i为虚数单位}则复数Z在复平面上所对应的点位于几象限我算的是3+ 2020-07-03 …
相位差为±90℃电压都超前于电流吗?若φ=Ψu-Ψi=0°,这时就称u与i相位相同,或者说u与i同 2020-07-30 …
1、a为正实数,i为虚数单位,|(a+i)/i|=2,则a=()A.2B.√3C.√2D.12、设 2020-07-30 …
若(1+2ai)*i=1-b*i,其中a、b∈R,i是虚数单位,则|a+b*i|=?已知0<a<2 2020-07-30 …
设i是虚数单位,复数i3+2i1+i=()A.1B.-1C.iD.-设i是虚数单位,复数i3+2i 2020-08-02 …
i是虚数单位,复数3+i1-i=()A.1+2iB.2+4iC.-1-2iD.2-i是虚数单位,复 2020-08-02 …
线性代数1.已知A^2+2A+2I=0,I是n阶单位阵,则(A+I)^(-1)=?2线性代数1.已知 2020-11-02 …