Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public class Rectangle extends Shape {
  2.    
  3.     private int width;
  4.    
  5.     private int height;
  6.    
  7.     public int getArea() {
  8.        
  9.         return height * width;     
  10.     }
  11.    
  12.     public String toString() {
  13.        
  14.         return "The Rectangle has a width of " + width + " and a height of " + height + super.toString();
  15.     }
  16.    
  17.     public int getWidth() {
  18.        
  19.         return width;
  20.     }
  21.    
  22.     public void setWidth(int newWidth) {
  23.        
  24.         this.width = newWidth; 
  25.     }
  26.    
  27.     public int getHeight() {
  28.        
  29.         return height;
  30.     }
  31.    
  32.     public void setHeight(int newHeight) {
  33.        
  34.         this.height = newHeight;
  35.     }
  36.    
  37.     Rectangle() {
  38.        
  39.         super(4);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement