毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 报告 >> 正文

JAVA上机实验求圆的面积和周长 第3页

更新时间:2007-10-3:  来源:毕业论文
 

    public Rectangle(double value) {

       this(value, value);

    }

 

    public Rectangle(double length, double width) {

       this.length = length;

       this.width = width;

    }

 

    @Override

    public String toString() {

       return "My real Class is:" + Rectangle.class.getName()

              + "\nMy length is:" + length + "\nMy width is:" + width

              + "\nMy area is:" + area() + "\nMy perimeter is:" + perimeter();

    }

 

    @Override

    public double area() {

       return length * width;

    }

 

    @Override

    public double perimeter() {

       return 2 * (length + width);

    }

 

    @Override

    public void draw() {

       Logger logger = Logger.getLogger("INFO");

       logger.info("draw()");

       System.out.println(message());

    }

 

    public double getLength() {

       return length;

    }

 

    public void setLength(double length) {

       this.length = length;

    }

 

    public double getWidth() {

       return width;

    }

 

    public void setWidth(double width) {

       this.width = width;

    }

 

}

 

package fox.math.kmust;

 

/**

 * @file Test.java

 */

public final class Test {

    public static void main(String[] args) {

       Shape shape = null;

       shape = new Circle();

       getShapeData(shape);

       if (Graph.class.isInstance(shape)) {

           drawGraph((Graph) shape);

       }

       System.out.println("-----The Line For Fox" + "-----TLFF-----"

              + "The Line For Fox-----");

       shape = new Rectangle(3.0);

       getShapeData(shape);

       if (Graph.class.isInstance(shape)) {

           drawGraph((Graph) shape);

       }

    }

 

    private static void getShapeData(Shape shape) {

       System.out.println("area:" + shape.area());

       System.out.println("perimeter:" + shape.perimeter());

    }

 

    private static void drawGraph(Graph graph) {

       graph.draw();

    }

} 

上一页  [1] [2] [3] [4] [5] 下一页

JAVA上机实验求圆的面积和周长 第3页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。