62,614
社区成员
发帖
与我相关
我的任务
分享
//Point.java
class Point
{
protected float x;
protected float y;
public void Set() //设置x,y
{
this.x=2.15f;
this.y=3.75f;
}
public float getX()//获取x
{
return x;
}
public float getY()//获取y
{
return y;
}
}
------------------------------------
//Circle.java
class Circle extends Point
{
protected float r;
public void Set()//设置半径
{
super.Set();
this.r=1.35f;
}
public float getR()//获取半径
{
return r;
}
public double getArea() //面积为double类型防止精度损失
{
return 3.14*r*r;
}
}
-------------------------------------------------
//Cylinder.java
class Cylinder extends Circle
{
protected float h;
public void Set()
{
super.Set();
this.h=4.56f;
}
public float getH()
{
return h;
}
public double getVolume()
{
return super.getArea()*h;
}
}
--------------------------
//Test.java
//建立Cylinder对象,输出其轴心位置坐标/半径/面积/高/及其体积的值
class Test
{
public static void main(String args[])
{
Cylinder cld=new Cylinder();
cld.Set();
System.out.print("轴心坐标为("+cld.x+","+cld.y+")半径为"+cld.r+",底面积为"+cld.getArea()+"高为"+cld.h+"体积为"+cld.getVolume());
}
}
//Point1.java
class Point1
{
protected float x;
protected float y;
public void Set(float x,float y) //设置x,y
{
this.x=x;
this.y=y;
}
public float getX()//获取x
{
return x;
}
public float getY()//获取y
{
return y;
}
}
-----------------------------------
//Circle1.java
class Circle1 extends Point1
{
protected float r;
public void Set(float x,float y,float r)//设置半径
{
super.Set(x,y);
this.r=r;
}
public float getR()//获取半径
{
return r;
}
public double getArea() //面积为double类型防止精度损失
{
return 3.14*r*r;
}
}
-----------------------
//Cylinder1.java
class Cylinder1 extends Circle1
{
protected float h;
public void Set(float x,float y,float r,float h)
{
super.Set(x,y,r);
this.h=h;
}
public float getH()
{
return h;
}
public double getVolume()
{
return super.getArea()*h;
}
}
-----------------------------------
//Test1.java
//建立Cylinder对象,输出其轴心位置坐标/半径/高/及其体积的值
class Test1
{
public static void main(String args[])
{
Cylinder1 cld=new Cylinder1();
cld.Set(2.15f,3.75f,1.35f,4.56f);
System.out.print("轴心坐标为("+cld.x+","+cld.y+")半径为"+cld.r+",底面积为"+cld.getArea()+"高为"+cld.h+"体积为"+cld.getVolume());
}
}
importXLS export=new importXLS("//localhost:1433","testJSP","sa","","test",title,thisfPathUp,isDeleteTableData);
//参数说明(依次):数据库地址,数据库名称,数据库用户名,数据库密码,表名,xls中有效字段,xls的路径,是否删除数据库表中的数据