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 = "
相关问答:
一个JSP页面接收其他页面提交过来的FORM表单,但是要求只接收当前站点及其子站点提交过来的FORM表单,其他站点提交过来的表单不接收,这个怎么设置?
用过滤器
filter
将当前站点及其子站点放一个目录
然 ......
我JSP的页面是:
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
有谁用java做过打印发票的程序,感觉这方面不是很好控制,希望给点建议,最好能给出代码
简单点就调用window.print()
你也可以把下面代码放到你JSP中:
<html>
<head>
<title> ......
使用java在windows7 32位下连接MSSQL。
两台机器,windows7 32位,在控制面板里面全部设置语言和区域选项都english-unitedstates
唯一区别只有在安装SQL server 2008的时候 选择的字符集不一样,
exec sp_helpsor ......