java定义一个点类(point),包含x,y坐标数据成员,显示函数(show)和计算面积(getarea)的函数成员
java定义一个点类(point),包含x,y坐标数据成员,显示函数(show)和计算面积(getarea)的函数成员。以点为父类构建一个圆类重载计算面积的函数;定义一个...
java定义一个点类(point),包含x,y坐标数据成员,显示函数(show)和计算面积(getarea)的函数成员。以点为父类构建一个圆类重载计算面积的函数;定义一个直线类,以两个点类对象作数据成员,定义显示,求面积及长度函数
明天要用啊 谢谢各位iT了 展开
明天要用啊 谢谢各位iT了 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏5(财富值+成长值)
展开全部
import java.lang.Math.*;
class point {
int x;
int y;
void show()
{
//don't know the purpose for this one.
}
double getarea()
{
return Math.sqrt(y*y + x*x);
}
}
class circirl extends point
{
int r;
double getarea(int r)
{
return (3.14*r*r);
}
}
public class line {
point point1;
point point2;
int getarea(point point1, point point2)
{
int length = point1.x - point2.x;
int width = point1.y - point2.y;
return Math.abs(width)*Math.abs(length);
}
double length(point point1, point point2)
{
int length = point1.x - point2.x;
int width = point1.y - point2.y;
double leng_point = Math.sqrt(length*length + width*width);
return leng_point;
}
public static void main(String[] args) {
line line =new line();
// circirl circirl = new circirl();
line.point1 = new point();
line.point1.x= 40;
line.point1.y= 40;
line.point2 = new point();
line.point2.x= 70;
line.point2.y= 90;
int len = line.getarea(line.point1,line.point2);
System.out.println("the len for the two point is "+len);
double sqre = line.length(line.point1,line.point2);
System.out.println("the squre for the two point is "+sqre);
}
}
class point {
int x;
int y;
void show()
{
//don't know the purpose for this one.
}
double getarea()
{
return Math.sqrt(y*y + x*x);
}
}
class circirl extends point
{
int r;
double getarea(int r)
{
return (3.14*r*r);
}
}
public class line {
point point1;
point point2;
int getarea(point point1, point point2)
{
int length = point1.x - point2.x;
int width = point1.y - point2.y;
return Math.abs(width)*Math.abs(length);
}
double length(point point1, point point2)
{
int length = point1.x - point2.x;
int width = point1.y - point2.y;
double leng_point = Math.sqrt(length*length + width*width);
return leng_point;
}
public static void main(String[] args) {
line line =new line();
// circirl circirl = new circirl();
line.point1 = new point();
line.point1.x= 40;
line.point1.y= 40;
line.point2 = new point();
line.point2.x= 70;
line.point2.y= 90;
int len = line.getarea(line.point1,line.point2);
System.out.println("the len for the two point is "+len);
double sqre = line.length(line.point1,line.point2);
System.out.println("the squre for the two point is "+sqre);
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询