?? ex4.java
字號:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package chenchao3;/** * * @author williechen */public class Ex4 {}interface Centered { void setCenter(double x, double y); double getCenterX(); double getCenterY();}class CenteredRectangle extends Rectangle implements Centered { // New instance fields private double cx, cy; // A constructor public CenteredRectangle(double cx, double cy, double w, double h) { super(w, h); this.cx = cx; this.cy = cy; } // We inherit all the methods of Rectangle but must // provide implementations of all the Centered methods. public void setCenter(double x, double y) { cx = x; cy = y; } public double getCenterX() { return cx; } public double getCenterY() { return cy; }}class CenteredCircle extends Circle implements Centered { // New instance fields private double cx, cy; // A constructor public CenteredCircle(double cx, double cy, double r) { super(r); this.cx = cx; this.cy = cy; } // We inherit all the methods of Rectangle but must // provide implementations of all the Centered methods. public void setCenter(double x, double y) { cx = x; cy = y; } public double getCenterX() { return cx; } public double getCenterY() { return cy; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -