java类 - Java / Java SE
要求圆柱继承圆,圆继承点。写出来很多错,请人指点
Java code:
class Point
{
int x, y;
public Point()
{
x = 0;
y = 0;
}
public Point(int newx, int newy)
{
x = newx >= 0 ? newx : 0;
y = newy >= 0 ? newy : 0;
}
public int get_x()
{
return x;
}
public int get_y()
{
return y;
}
public void set_x(int temp)
{
x = temp;
}
public void set_y(int temp)
{
y = temp;
}
}
class Circle extends Point
{
double r;
public Circle()
{
r = 0.0;
}
public Circle(int x, int y, double r)
{
super(x,y);
this.r = r;
}
public double get_r()
{
return r;
}
public void set_r(double newr)
{
this.r = newr;
}
public double cir_c()
{
return 2 * 3.1415926 * r;
}
public double cir_s()
{
return 3.1415926 * r * r;
}
}
class Column extends Circle
{
double h;
public Column()
{
h = 0;
}
public Column(int x, int y, double r, double h)
{
super(x, y, r);
this.h = h;
}
public double get_h()
{
return h;
}
public void set_h(double newh)
{
this.h = newh;
}
public double col_s()
{
return (2 * 3.1415926 * r * r + h * 2 * 3.1415926 * r);
}
public double col_v()
{
return (3.1415926 * r * r * h);
}
}
public class Test {
public static void main(String args[])
{
Column c = new Column(3,3,2.0,5.5);
System.out.println("X = "+c.get_x());
System.out.println("Y = "
相关问答:
题目:
有1,2,3,4,5,6六个数字排序,用java程序计算出排序的种类。
要求:一,以4开头
二,2,3不能相邻
三,不能以5开头
希望大家能即 ......
为什么HTML以及一些其它标签会显示一些特定表现形式呢?如HTML中的换行标签<BR/>在底层是怎样实现的呢?现实的原理是什么呢
去W3C官方网站上,看看吧!我想一看你就明白了
我猜和编译原理有关,浏览器里可 ......
table怎么绑定数据库,并且用JavaScript实现翻页。。。。。。。。。。JavaScript能向JSP页面传递参数吗
你说的问题有点那个。。,不好回答。。。。
jsp中table是需要html代码与页面端获取数据库查询后的信息进行 ......
我是个新手,望高手解答
我现在已经安装了mysql,也有mysql的jdbc。但我怎么配置后,才能在MyEclipse里操作mysql呢?请高手说详细点
打开Myeclipse----window---open perspective---MyEclipse database explorer-- ......
使用java在windows7 32位下连接MSSQL。
两台机器,windows7 32位,在控制面板里面全部设置语言和区域选项都english-unitedstates
唯一区别只有在安装SQL server 2008的时候 选择的字符集不一样,
exec sp_helpsor ......