Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.test.level05.lesson07.task05;
- /* Создать класс прямоугольник (Rectangle)
- Создать класс прямоугольник (Rectangle). Его данными будут top, left, width, height (левая координата, верхняя, ширина и высота). Создать для него как можно больше методов initialize(…)
- Примеры:
- - заданы 4 параметра: left, top, width, height
- - ширина/высота не задана (оба равны 0)
- - высота не задана (равно ширине) создаём квадрат
- - создаём копию другого прямоугольника (он и передаётся в параметрах)
- */
- public class Rectangle
- {
- int top;
- int left;
- int width;
- int height;
- public void initialize(int left, int top, int width, int height){
- this.left = left;
- this.top = top;
- this.width = width;
- this.height = height;
- }
- public void initialize(int left, int height){
- this.left = left;
- this.height = height;
- int width = 0;
- int top = 0;
- }
- public void initialize(int width){
- this.width = width;
- int height = width;
- }
- public void initialize(){
- this.initialize(left, height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement