Advertisement
aznGiLL

Rectangle

Mar 15th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package tutorial3;
  2. // Anders Gill
  3.  
  4. public class Rectangle {
  5.     private int height;
  6.     private int width;
  7.     private String color;
  8.    
  9.     public Rectangle(){
  10.        
  11.     }
  12.    
  13.     public void setHeight(int height){
  14.         this.height = height;
  15.     }
  16.    
  17.     public void setWidth(int width){
  18.         this.width = width;
  19.     }
  20.    
  21.     public void setColor(String color){
  22.         this.color = color;
  23.     }
  24.    
  25.     public int getHeight(){
  26.         return height;
  27.     }
  28.    
  29.     public int getWidth(){
  30.         return width;
  31.     }
  32.    
  33.     public String getColor(){
  34.         return color;
  35.     }
  36.    
  37.     public int getArea(){
  38.         return width * height;
  39.     }
  40.  
  41.     public int getPerimeter(){
  42.         return (height + width) * 2;
  43.     }
  44.    
  45.     public String toString(){
  46.         return "Height    : " + getHeight() + "\nWidth     : " + getWidth() + "\nColor     : " + getColor() + "\nArea      : " + getArea() + "\nPerimeter : " + getPerimeter();
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement