import java.awt.*;
import java.util.Scanner;
abstract class Figure {
protected int x;
protected int y;
public static int count;
public static int Count(){
return count;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
abstract void draw();
abstract void move();
}
class Line extends Figure
{ int x2;
int y2;
Line(int k1,
int l1,
int k2,
int l2
) { count++;
super.x = k1;
super.y = l1;
x2 = k2;
y2 = l2;
}
void draw() {
System.
out.
println("Координаты:"); System.
out.
println("(x1;y1):" + "(" + x
+ ";" + y
+ ")"); System.
out.
println("(x2;y2):" + "(" + x2
+ ";" + y2
+ ")"); }
void move() {
Scanner scanner
= new Scanner
(System.
in); System.
out.
println("Сдвинуть фигуру"); System.
out.
print("По оси X: "); int t = scanner.nextInt();
System.
out.
print("По оси Y: "); int t2 = scanner.nextInt();
x = x + t;
x2 = x2 + t;
y = y + t2;
y2 = y2 + t2;
System.
out.
println("Новые координаты фигуры: "); System.
out.
println("(x1;y1):" + "(" + x
+ ";" + y
+ ")"); System.
out.
println("(x2;y2):" + "(" + x2
+ ";" + y2
+ ")"); }
}
int x2;
int y2;
int x3;
int y3;
int x4;
int y4;
count++;
super.x = k1;
super.y = l1;
x2 = x;
y2 = l2;
x3 = k3;
y3 = y;
x4 = x3;
y4 = y2;
}
void draw() {
System.
out.
println("Прямоугольник"); System.
out.
println("Координаты:"); System.
out.
println("(x1;y1):" + "(" + x
+ ";" + y
+ ")"); System.
out.
println("(x2;y2):" + "(" + x2
+ ";" + y2
+ ")"); System.
out.
println("(x3;y3):" + "(" + x3
+ ";" + y3
+ ")"); System.
out.
println("(x4;y4):" + "(" + x4
+ ";" + y4
+ ")"); }
void move() {
Scanner scanner
= new Scanner
(System.
in); System.
out.
println("Сдвинуть фигуру"); System.
out.
print("По оси X: "); int t = scanner.nextInt();
System.
out.
print("По оси Y: "); int t2 = scanner.nextInt();
x = x + t;
x2 = x2 + t;
x3 = x3 + t;
x4 = x4 + t;
y = y + t2;
y2 = y2 + t2;
y3 = y3 + t2;
y4 = y4 + t2;
System.
out.
println("Новые координаты фигуры: "); System.
out.
println("(x1;y1):" + "(" + x
+ ";" + y
+ ")"); System.
out.
println("(x2;y2):" + "(" + x2
+ ";" + y2
+ ")"); System.
out.
println("(x3;y3):" + "(" + x3
+ ";" + y3
+ ")"); System.
out.
println("(x4;y4):" + "(" + x4
+ ";" + y4
+ ")"); }
}
class Circle extends Figure {
int r;
Circle(int k1, int l1, int u) {
count++;
super.x = k1;
super.y = l1;
r = u;
}
void draw() {
System.
out.
println("Координаты:"); System.
out.
println("Центр (x;y):" + "(" + x
+ ";" + y
+ ")"); System.
out.
println("Верхняя точка: " + "(" + x
+ ";" + (y
+ r
) + ")"); System.
out.
println("Левая точка: " + "(" + (x
- r
) + ";" + y
+ ")"); System.
out.
println("Нижняя точка: " + "(" + x
+ ";" + (y
- r
) + ")"); System.
out.
println("Правая точка: " + "(" + (x
+ r
) + ";" + y
+ ")"); }
void move() {
Scanner scanner
= new Scanner
(System.
in); System.
out.
println("Сдвинуть фигуру"); System.
out.
print("По оси X: "); int t = scanner.nextInt();
System.
out.
print("По оси Y: "); int t2 = scanner.nextInt();
x = x + t;
y = y + t2;
System.
out.
println("Новые координаты фигуры: "); System.
out.
println("Центр (x;y):" + "(" + x
+ ";" + y
+ ")"); System.
out.
println("Верхняя точка: " + "(" + x
+ ";" + (y
+ r
) + ")"); System.
out.
println("Левая точка: " + "(" + (x
- r
) + ";" + y
+ ")"); System.
out.
println("Нижняя точка: " + "(" + x
+ ";" + (y
- r
) + ")"); System.
out.
println("Правая точка: " + "(" + (x
+ r
) + ";" + y
+ ")"); }
}
class CompositeFigure extends Figure {
int[] intAry = new int[10];
Figure
[]Array = new Figure
[]{ new Circle(2, 2, 4),
};
CompositeFigure(int i) {
}
void draw() { //Что делать с этими методами?
}
void move() {
}
}
class Activity {
public static void main
(String[] args
) { Circle circle = new Circle(0, 0, 2);
line.draw();
line.move();
rectangle.draw();
rectangle.move();
circle.draw();
circle.move();
//CompositeFigure.draw(); //Как здесь?
System.
out.
print(Count
()); //Как здесь?
}
}
aW1wb3J0IGphdmEuYXd0Lio7CmltcG9ydCBqYXZhLnV0aWwuU2Nhbm5lcjsKCmFic3RyYWN0IGNsYXNzIEZpZ3VyZSB7CiAgICBwcm90ZWN0ZWQgaW50IHg7CiAgICBwcm90ZWN0ZWQgaW50IHk7CiAgICBwdWJsaWMgc3RhdGljIGludCBjb3VudDsKICAgIHB1YmxpYyBzdGF0aWMgaW50IENvdW50KCl7CiAgICAgICAgcmV0dXJuIGNvdW50OwoKICAgIH0KCiAgICBwdWJsaWMgaW50IGdldFgoKSB7CiAgICAgICAgcmV0dXJuIHg7CiAgICB9CgogICAgcHVibGljIGludCBnZXRZKCkgewogICAgICAgIHJldHVybiB5OwogICAgfQoKICAgIHB1YmxpYyB2b2lkIHNldFgoaW50IHgpIHsKICAgICAgICB0aGlzLnggPSB4OwogICAgfQoKICAgIHB1YmxpYyB2b2lkIHNldFkoaW50IHkpIHsKICAgICAgICB0aGlzLnkgPSB5OwogICAgfQoKICAgIGFic3RyYWN0IHZvaWQgZHJhdygpOwoKICAgIGFic3RyYWN0IHZvaWQgbW92ZSgpOwp9CgogY2xhc3MgTGluZSBleHRlbmRzIEZpZ3VyZSB7CiAgICAgaW50IHgyOwogICAgIGludCB5MjsKCgogICAgIExpbmUoaW50IGsxLCBpbnQgbDEsIGludCBrMiwgaW50IGwyKSB7CiAgICAgICAgIGNvdW50Kys7CiAgICAgICAgIHN1cGVyLnggPSBrMTsKICAgICAgICAgc3VwZXIueSA9IGwxOwogICAgICAgICB4MiA9IGsyOwogICAgICAgICB5MiA9IGwyOwoKCiAgICAgfQogICAgIHZvaWQgZHJhdygpIHsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQm9C40L3QuNGPIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0JrQvtC+0YDQtNC40L3QsNGC0Ys6Iik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiKHgxO3kxKToiICsgIigiICsgeCArICI7IiArIHkgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4Mjt5Mik6IiArICIoIiArIHgyICsgIjsiICsgeTIgKyAiKSIpOwogICAgIH0KCiAgICAgdm9pZCBtb3ZlKCkgewogICAgICAgICBTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCh0LTQstC40L3Rg9GC0Ywg0YTQuNCz0YPRgNGDIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoItCf0L4g0L7RgdC4IFg6ICIpOwogICAgICAgICBpbnQgdCA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCLQn9C+INC+0YHQuCBZOiAiKTsKICAgICAgICAgaW50IHQyID0gc2Nhbm5lci5uZXh0SW50KCk7CiAgICAgICAgIHggPSB4ICsgdDsKICAgICAgICAgeDIgPSB4MiArIHQ7CiAgICAgICAgIHkgPSB5ICsgdDI7CiAgICAgICAgIHkyID0geTIgKyB0MjsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQndC+0LLRi9C1INC60L7QvtGA0LTQuNC90LDRgtGLINGE0LjQs9GD0YDRizogIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiKHgxO3kxKToiICsgIigiICsgeCArICI7IiArIHkgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4Mjt5Mik6IiArICIoIiArIHgyICsgIjsiICsgeTIgKyAiKSIpOwogICAgIH0KIH0KIGNsYXNzIFJlY3RhbmdsZSBleHRlbmRzIEZpZ3VyZSB7CgogICAgIGludCB4MjsKICAgICBpbnQgeTI7CiAgICAgaW50IHgzOwogICAgIGludCB5MzsKICAgICBpbnQgeDQ7CiAgICAgaW50IHk0OwoKICAgIFJlY3RhbmdsZShpbnQgazEsIGludCBsMSwgaW50IGwyLCBpbnQgazMpIHsKICAgICAgICAgY291bnQrKzsKICAgICAgICAgc3VwZXIueCA9IGsxOwogICAgICAgICBzdXBlci55ID0gbDE7CiAgICAgICAgIHgyID0geDsKICAgICAgICAgeTIgPSBsMjsKICAgICAgICAgeDMgPSBrMzsKICAgICAgICAgeTMgPSB5OwogICAgICAgICB4NCA9IHgzOwogICAgICAgICB5NCA9IHkyOwogICAgIH0KCiAgICAgdm9pZCBkcmF3KCkgewoKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQn9GA0Y/QvNC+0YPQs9C+0LvRjNC90LjQuiIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCa0L7QvtGA0LTQuNC90LDRgtGLOiIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4MTt5MSk6IiArICIoIiArIHggKyAiOyIgKyB5ICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDI7eTIpOiIgKyAiKCIgKyB4MiArICI7IiArIHkyICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDM7eTMpOiIgKyAiKCIgKyB4MyArICI7IiArIHkzICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDQ7eTQpOiIgKyAiKCIgKyB4NCArICI7IiArIHk0ICsgIikiKTsKICAgICB9CgogICAgIHZvaWQgbW92ZSgpIHsKICAgICAgICAgU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQodC00LLQuNC90YPRgtGMINGE0LjQs9GD0YDRgyIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCLQn9C+INC+0YHQuCBYOiAiKTsKICAgICAgICAgaW50IHQgPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludCgi0J/QviDQvtGB0LggWTogIik7CiAgICAgICAgIGludCB0MiA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgICB4ID0geCArIHQ7CiAgICAgICAgIHgyID0geDIgKyB0OwogICAgICAgICB4MyA9IHgzICsgdDsKICAgICAgICAgeDQgPSB4NCArIHQ7CiAgICAgICAgIHkgPSB5ICsgdDI7CiAgICAgICAgIHkyID0geTIgKyB0MjsKICAgICAgICAgeTMgPSB5MyArIHQyOwogICAgICAgICB5NCA9IHk0ICsgdDI7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0J3QvtCy0YvQtSDQutC+0L7RgNC00LjQvdCw0YLRiyDRhNC40LPRg9GA0Ys6ICIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4MTt5MSk6IiArICIoIiArIHggKyAiOyIgKyB5ICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDI7eTIpOiIgKyAiKCIgKyB4MiArICI7IiArIHkyICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDM7eTMpOiIgKyAiKCIgKyB4MyArICI7IiArIHkzICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDQ7eTQpOiIgKyAiKCIgKyB4NCArICI7IiArIHk0ICsgIikiKTsKICAgICB9CiB9CiBjbGFzcyBDaXJjbGUgZXh0ZW5kcyBGaWd1cmUgewogICAgIGludCByOwoKICAgICBDaXJjbGUoaW50IGsxLCBpbnQgbDEsIGludCB1KSB7CiAgICAgICAgIGNvdW50Kys7CiAgICAgICAgIHN1cGVyLnggPSBrMTsKICAgICAgICAgc3VwZXIueSA9IGwxOwogICAgICAgICByID0gdTsKICAgICB9CgogICAgIHZvaWQgZHJhdygpIHsKCiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0JrRgNGD0LMiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQmtC+0L7RgNC00LjQvdCw0YLRizoiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQptC10L3RgtGAICh4O3kpOiIgKyAiKCIgKyB4ICsgIjsiICsgeSArICIpIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0JLQtdGA0YXQvdGP0Y8g0YLQvtGH0LrQsDogIiArICIoIiArIHggKyAiOyIgKyAoeSArIHIpICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQm9C10LLQsNGPINGC0L7Rh9C60LA6ICIgKyAiKCIgKyAoeCAtIHIpICsgIjsiICsgeSArICIpIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0J3QuNC20L3Rj9GPINGC0L7Rh9C60LA6ICIgKyAiKCIgKyB4ICsgIjsiICsgKHkgLSByKSArICIpIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0J/RgNCw0LLQsNGPINGC0L7Rh9C60LA6ICIgKyAiKCIgKyAoeCArIHIpICsgIjsiICsgeSArICIpIik7CiAgICAgfQoKICAgICB2b2lkIG1vdmUoKSB7CiAgICAgICAgIFNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0KHQtNCy0LjQvdGD0YLRjCDRhNC40LPRg9GA0YMiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludCgi0J/QviDQvtGB0LggWDogIik7CiAgICAgICAgIGludCB0ID0gc2Nhbm5lci5uZXh0SW50KCk7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoItCf0L4g0L7RgdC4IFk6ICIpOwogICAgICAgICBpbnQgdDIgPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgeCA9IHggKyB0OwogICAgICAgICB5ID0geSArIHQyOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCd0L7QstGL0LUg0LrQvtC+0YDQtNC40L3QsNGC0Ys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