Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rectangle{//class header
- //data - instance variables
- private double length, width;
- //functionality - methods
- public void setLength( double len ){
- length = len;
- }
- public void setWidth( double wid ){
- width = wid;
- }
- public double area(){
- return length * width;
- }
- public double perimeter(){
- return 2 * length + 2 * width;
- }
- public double diagonal(){
- return Math.sqrt( Math.pow(width,2) + Math.pow(length,2) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement