zoukankan      html  css  js  c++  java
  • 12

     1 public class L1106 {
     2   
     3       public static void main(String[] args) {
     4           // TODO Auto-generated method stub
     5           TestDemo circle1 = new TestDemo();
     6           double area=circle1.getArea();
     7           System.out.println(area);
     8           TestDemo circle2=new TestDemo(10);
     9           System.out.println(circle2.getArea());
    10         System.out.println(circle1.getPerimeter());
    11          System.out.println(circle2.getPerimeter());
    12          double ridius=10;
    13          double areaCircle=Math.PI*ridius*ridius;
    14          System.out.println(areaCircle);
    15          circle2.setRadius(5);
    16          System.out.println(circle2.getArea());
    17      }
    18  
    19  }
    20 
    21 
    22 
    23 
    24 public class TestDemo {
    25   
    26   private double radius;
    27       
    28       public TestDemo(double radius) {
    29           this.radius = radius;
    30       }
    31       public TestDemo() {
    32           this.radius = 1.0;
    33      }
    34      public double getArea() {
    35          return Math.PI * radius * radius;
    36      }
    37      public double getPerimeter() {
    38          return 2 * Math.PI * radius;
    39      }
    40      public void setRadius(double newRadius) {
    41          this.radius = newRadius;
    42      }
    43  }

  • 相关阅读:
    TIDB-存储
    MySQL的ACID
    MySQL MVCC
    MySQL 悲观锁、乐观锁、MVCC一
    MySQL写放大总结
    基于Linux上的wifi密码爆破
    Stack与Queue的实现(c++模板实现)
    vector 实现二维数组
    Linux下的静态链接与动态链接
    260. Single Number III
  • 原文地址:https://www.cnblogs.com/a718204806/p/8057435.html
Copyright © 2011-2022 走看看