package javahomework; public class HW15 { class Point { private double x, y; public Point() { x = 1.0; y = 1.0; } public Point(double n1, double n2) { x = n1; y = n2; } public double getX() { return x; } public double getY() { return y; } } class Circle{ private double r; private Point p; public double pi = 3.1415926; Circle() { r = 1.0; } public double findArea() { return r * r * pi; } public double findlength() { return r * pi * 2; } public void set(double n,Point p) { r = n; } public double get_r() { return r; } public Point get_Point(){ return p; } public void set_Point(Point p){ this.p = p; } } class Cone extends Circle { private double r = super.get_r(); private double h; Cone() { h = 1.0; } Cone(double n1, double n2) { r = n1; h = n2; } public void set(double n1, double n2) { r = n1; h = n2; } public double getR() { return r; } public double getH() { return h; } public double findVolume() { return (pi * r * r * h) / 3; } public double findFaceArea() { return (Math.pow((r * r) + (h * h), 0.5)) * 2 * pi; } } class DouleCone extends Cone { private double r = super.getR(); private double h = super.getH(); public double findDoublejVolume() { return super.findVolume() * 2; } public double findDoubleH() { return h * 2; } public double findDoubleVolume() { return super.findVolume() * 2; } public double findDoubleFaceArea1() {// 漏斗 return super.findFaceArea() * 2; } public double findDoubleFaceArea2() {// 兩邊尖 return (super.findFaceArea() * 2) - (r * r * pi) * 2; } } }
2008年8月29日 星期五
定義一個點->圓->圓錐體->雙圓錐體
code
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言