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 = "
相关问答:
当知道一个日期,如何把这个日期所在旬的前后两个日期取出
比如输入20090905,就输入20090901 20090910
输出20090901 20090910
取得天数后作一下判断再把这个方法用下void set(int field, int value)
......
一个JSP页面接收其他页面提交过来的FORM表单,但是要求只接收当前站点及其子站点提交过来的FORM表单,其他站点提交过来的表单不接收,这个怎么设置?
用过滤器
filter
将当前站点及其子站点放一个目录
然 ......
有谁用java做过打印发票的程序,感觉这方面不是很好控制,希望给点建议,最好能给出代码
简单点就调用window.print()
你也可以把下面代码放到你JSP中:
<html>
<head>
<title> ......
大家好,我现在有一个用asp写的聊天室,现在的想添加一个功能,就是当有人上线的时候,发出提示,比如声音响一下,现在想用java实现这个功能,请问大家怎么实现?
谢谢了,我会加分的
asp和java整合到一起去?何必 ......
我写了个jsp页面,然后改动了一下,改动的内容就是在jsp页面的js函数里加了个alert()语句,但是我访问这个页面时,死活都是原来页面的内容,我加了很多alert函数还是没改动前的页面内容;tomcat重启了,也重新部署这 ......