⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex4.java

📁 讲述各种各样的java初始编程 了解编程
💻 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 + -