Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. public class Rectangle extends GeometricObject {
  2.       private double width;
  3.       private double height;
  4.  
  5.       public Rectangle() {
  6.       }
  7.  
  8.       public Rectangle(double width, double height) {
  9.         this.width = width;
  10.         this.height = height;
  11.       }
  12.  
  13.       /** Return width */
  14.       public double getWidth() {
  15.         return width;
  16.       }
  17.  
  18.       /** Set a new width */
  19.       public void setWidth(double width) {
  20.         this.width = width;
  21.       }
  22.  
  23.       /** Return height */
  24.       public double getHeight() {
  25.         return height;
  26.       }
  27.  
  28.       /** Set a new height */
  29.       public void setHeight(double height) {
  30.         this.height = height;
  31.       }
  32.  
  33.       @Override /** Return area */
  34.       public double getArea() {
  35.         return width * height;
  36.       }
  37.  
  38.       @Override /** Return perimeter */
  39.       public double getPerimeter() {
  40.         return 2 * (width + height);
  41.       }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement