Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Rectangle;
- //business layer
- public class Rectangle
- {
- //hard code instance variables
- //Encapsulation
- private int length;
- private int width;
- //create a constructor
- public Rectangle(int length, int width)
- {
- length = 0;
- width = 0;
- }
- //the setter and getter for the instance variables
- public void setLength(int length)
- {
- this.length = length;
- }
- public int getLength()
- {
- return length;
- }
- public void setWidth(int width)
- {
- this.width = width;
- }
- public int getWidth()
- {
- return width;
- }
- //are and permieter
- public int area()
- {
- return length * width;
- }
- public int per()
- {
- return (length + width) * 2;
- }
- }
Add Comment
Please, Sign In to add comment