📄 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 + -