Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RunRectangle {
- public static void main(String[] args) {
- Rectangle r1 = new Rectangle(3, 3);
- System.out.println(r1); // toString()
- Rectangle r2 = new Rectangle(7, 10);
- System.out.println(r2);
- // Test setters and getters
- r1.setLength(5.6);
- r1.setWidth(7.8);
- System.out.println(r1); // toString()
- System.out.println("length is: " + r1.getLength());
- System.out.println("width is: " + r1.getWidth());
- // Test getArea() and getPerimeter()
- System.out.printf("area is: %f", r1.getArea());
- System.out.printf("perimeter is: %f", r1.getPerimeter());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement