zoukankan      html  css  js  c++  java
  • 1.(1)编写一个接口ShapePara,要求: 接口中的方法: int getArea():获得图形的面积。int getCircumference():获得图形的周长 (2)编写一个圆类Circle,要求:圆类Circle实现接口ShapePara。 该类包含有成员变量: radius:public 修饰的double类型radius,表示圆的半径。 x:private修饰的double型变量

    //接口 ShapePara

    package d922B;

    public interface ShapePara {
    int getArea();
    int getCircumference();

    }

    //圆类
    package d922B;

    public class Circle implements ShapePara {
    public double radius;
    private double x;
    protected double y;
    Circle(double r)
    {
    radius=r;
    x=0;
    y=0;
    }
    double getRadius()
    {
    return radius;
    }
    void setCenter(double a, double b)
    {
    x=a;
    y=b;
    }
    void setRadius(double r)
    {
    radius=r;
    }
    public int getArea() {

    	return(int) (Math.PI*radius*radius);
    }
    
    public int getCircumference() {
    	
    	return (int) (2*Math.PI*radius);
    }
    

    }

  • 相关阅读:
    ReentrantLock和AQS
    CAS
    java8中ConcurrentHashMap
    java8中的HashMap
    TCP和UDP
    慢查询日志和profiling
    explain的使用
    select、poll、epoll之间的区别
    I/O模型
    生产者-消费者模式
  • 原文地址:https://www.cnblogs.com/nicebaby/p/5897691.html
Copyright © 2011-2022 走看看