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

📄 shape.java

📁 Beginning Java 2, SDK 1.4 Edition Exercise Code samples for this book
💻 JAVA
字号:
// Chapter 6 Exercise 3

// BASE CLASS FOR SHAPES - it is still an abstract class since it does not
// implement the show() method declared in the ShapeInterface. 
// The move() method that  is implemented here assumes shapes are defined 
// relative to the reference point, position, so subclasses of this class
// must be defined in this way. Where this is not convenient an alternative is
// to implement a separate move() method in each derived class.

public abstract class Shape implements ShapeInterface {
  protected Point position;     // Position of a shape.

  // Method to move a shape:
  public void move(double xDelta, double yDelta)
  {
    // Move the shape by xDelta in x, and yDelta in y:
    position.x += xDelta;		
    position.y += yDelta;
  }

}

⌨️ 快捷键说明

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