Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Rectangle {
- int length;
- int width;
- Rectangle(){
- length = 1;
- width = 1;
- }
- Rectangle(int x, int y){
- if(x <= 0 || y <= 0){
- length = 1;
- width = 1;
- }
- else{
- length = x;
- width = y;
- }
- }
- public int perimeter(){
- return (2*getLength() + 2*getWidth());
- }
- public int area(){
- return getLength()*getWidth();
- }
- public int getLength(){
- return length;
- }
- public int getWidth(){
- return width;
- }
- }
Add Comment
Please, Sign In to add comment