Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main
- {
- public static void main(String[] args)
- {
- Rectangle rect = new Rectangle(100, 200);
- System.out.println(rect.getWidth());
- System.out.println(rect.getHeight());
- rect.setWidth(10);
- rect.setHeight(20);
- rect.scale(10);
- System.out.println(rect.getArea());
- }
- }
- class Rectangle
- {
- int width;
- int height;
- int factor;
- Rectangle(int width, int height)
- {
- this.width = width;
- this.height = height;
- }
- void setHeight(int height)
- {
- this.height = height;
- }
- void setWidth(int width)
- {
- this.width = width;
- }
- int getWidth()
- {
- return this.width;
- }
- int getHeight()
- {
- return this.height;
- }
- void scale(int factor)
- {
- width = width * factor;
- height = height * factor;
- }
- int getArea()
- {
- return this.width * this.height;
- }
- 100
- 200
- 20000
- public class Main
- {
- public static void main(String[] args)
- {
- Rectangle rect = new Rectangle(100, 200);
- System.out.println(rect.getWidth());
- System.out.println(rect.getHeight());
- rect.setWidth(10);
- rect.setHeight(20);
- System.out.println(rect.getArea());
- rect.scale(10);
- System.out.println(rect.getArea());
- }
- }
- rect.scale(10);
- System.out.println(rect.getArea());
Add Comment
Please, Sign In to add comment