Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tutorial3;
- // Anders Gill
- public class Rectangle {
- private int height;
- private int width;
- private String color;
- public Rectangle(){
- }
- public void setHeight(int height){
- this.height = height;
- }
- public void setWidth(int width){
- this.width = width;
- }
- public void setColor(String color){
- this.color = color;
- }
- public int getHeight(){
- return height;
- }
- public int getWidth(){
- return width;
- }
- public String getColor(){
- return color;
- }
- public int getArea(){
- return width * height;
- }
- public int getPerimeter(){
- return (height + width) * 2;
- }
- public String toString(){
- return "Height : " + getHeight() + "\nWidth : " + getWidth() + "\nColor : " + getColor() + "\nArea : " + getArea() + "\nPerimeter : " + getPerimeter();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement