iawitm

Untitled

Dec 3rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. package shape;
  2.  
  3. public class Square extends Rectangle {
  4.  
  5.     public Square(){}
  6.  
  7.     public Square(double side){
  8.         this.width = side;
  9.         this.length = side;
  10.     }
  11.  
  12.     public Square(double side, String color, boolean filled){
  13.         this.length = side;
  14.         this.width = side;
  15.         this.color = color;
  16.         this.filled = filled;
  17.     }
  18.  
  19.     public double getSide(){
  20.         return length;
  21.     }
  22.  
  23.     public void setSide(double side){
  24.         setLength(side);
  25.         setWidth(side);
  26.     }
  27.  
  28.     @Override
  29.     public String toString() {
  30.         return "Side: "+getSide()+", color: "+getColor()+", filled: "+isFilled()+", area: "+getArea()+", perimetr: "+getPerimetr();
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment