circle.java

来自「Beginning Java 2, SDK 1.4 Edition Exerci」· Java 代码 · 共 23 行

JAVA
23
字号
// Chapter 6 Exercises 1 & 2

public class Circle extends Shape {
  private double radius;	// Radius of circle.

  // Constructors:
  public Circle(Point center, double radius) {
    // Center of the circle is the position:
    position = new Point(center);  // Store position - new Point object for independence.
    this.radius = radius;	         // Store the radius.
  }
 
  // Overrides method inherited from Object:
  public String toString() { 
    // Create a string representation of the object:					
    return "Circle: Center " + position + " Radius " + radius;
  }

  public void show() {					
    System.out.println("\n" + toString());
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?