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