import java.util.Scanner;
abstract class Figure {
protected int x;
protected int y;
public static int count;
public static int getCount(){
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 {
CompositeFigure() {
Figure[] figures = new Figure[3];
figures
[0] = new Line(1,
1,
5,
5); figures[2] = new Circle(1, 4, 5);
}
void draw() {
}
void move() {
}
}
class Activity {
public static void main
(String[] args
) { Circle circle = new Circle(0, 0, 2);
Figure[] figures = new Figure[3];
line.draw();
rectangle.draw();
circle.draw();
figures[0] = line;
figures[1] = circle;
figures[2] = rectangle;
for(int n = 0; n < 3; n++)
figures[n].draw();
System.
out.
print(Figure.
getCount()); }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKYWJzdHJhY3QgY2xhc3MgRmlndXJlIHsKICAgIHByb3RlY3RlZCBpbnQgeDsKICAgIHByb3RlY3RlZCBpbnQgeTsKICAgIHB1YmxpYyBzdGF0aWMgaW50IGNvdW50OwogICAgcHVibGljIHN0YXRpYyBpbnQgZ2V0Q291bnQoKXsKICAgICAgICByZXR1cm4gY291bnQ7CiAgICB9CgogICAgcHVibGljIGludCBnZXRYKCkgewogICAgICAgIHJldHVybiB4OwogICAgfQoKICAgIHB1YmxpYyBpbnQgZ2V0WSgpIHsKICAgICAgICByZXR1cm4geTsKICAgIH0KCiAgICBwdWJsaWMgdm9pZCBzZXRYKGludCB4KSB7CiAgICAgICAgdGhpcy54ID0geDsKICAgIH0KCiAgICBwdWJsaWMgdm9pZCBzZXRZKGludCB5KSB7CiAgICAgICAgdGhpcy55ID0geTsKICAgIH0KCiAgICBhYnN0cmFjdCB2b2lkIGRyYXcoKTsKCiAgICBhYnN0cmFjdCB2b2lkIG1vdmUoKTsKfQoKIGNsYXNzIExpbmUgZXh0ZW5kcyBGaWd1cmUgewogICAgIGludCB4MjsKICAgICBpbnQgeTI7CgoKICAgICBMaW5lKGludCBrMSwgaW50IGwxLCBpbnQgazIsIGludCBsMikgewogICAgICAgICBjb3VudCsrOwogICAgICAgICBzdXBlci54ID0gazE7CiAgICAgICAgIHN1cGVyLnkgPSBsMTsKICAgICAgICAgeDIgPSBrMjsKICAgICAgICAgeTIgPSBsMjsKCgogICAgIH0KCiAgICAgdm9pZCBkcmF3KCkgewogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCb0LjQvdC40Y8iKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQmtC+0L7RgNC00LjQvdCw0YLRizoiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDE7eTEpOiIgKyAiKCIgKyB4ICsgIjsiICsgeSArICIpIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiKHgyO3kyKToiICsgIigiICsgeDIgKyAiOyIgKyB5MiArICIpIik7CiAgICAgfQoKICAgICB2b2lkIG1vdmUoKSB7CiAgICAgICAgIFNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0KHQtNCy0LjQvdGD0YLRjCDRhNC40LPRg9GA0YMiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludCgi0J/QviDQvtGB0LggWDogIik7CiAgICAgICAgIGludCB0ID0gc2Nhbm5lci5uZXh0SW50KCk7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoItCf0L4g0L7RgdC4IFk6ICIpOwogICAgICAgICBpbnQgdDIgPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgeCA9IHggKyB0OwogICAgICAgICB4MiA9IHgyICsgdDsKICAgICAgICAgeSA9IHkgKyB0MjsKICAgICAgICAgeTIgPSB5MiArIHQyOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCd0L7QstGL0LUg0LrQvtC+0YDQtNC40L3QsNGC0Ysg0YTQuNCz0YPRgNGLOiAiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIoeDE7eTEpOiIgKyAiKCIgKyB4ICsgIjsiICsgeSArICIpIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiKHgyO3kyKToiICsgIigiICsgeDIgKyAiOyIgKyB5MiArICIpIik7CiAgICAgfQogfQogY2xhc3MgUmVjdGFuZ2xlIGV4dGVuZHMgRmlndXJlIHsKCiAgICAgaW50IHgyOwogICAgIGludCB5MjsKICAgICBpbnQgeDM7CiAgICAgaW50IHkzOwogICAgIGludCB4NDsKICAgICBpbnQgeTQ7CgogICAgUmVjdGFuZ2xlKGludCBrMSwgaW50IGwxLCBpbnQgbDIsIGludCBrMykgewogICAgICAgICBjb3VudCsrOwogICAgICAgICBzdXBlci54ID0gazE7CiAgICAgICAgIHN1cGVyLnkgPSBsMTsKICAgICAgICAgeDIgPSB4OwogICAgICAgICB5MiA9IGwyOwogICAgICAgICB4MyA9IGszOwogICAgICAgICB5MyA9IHk7CiAgICAgICAgIHg0ID0geDM7CiAgICAgICAgIHk0ID0geTI7CiAgICAgfQoKICAgICB2b2lkIGRyYXcoKSB7CgogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCf0YDRj9C80L7Rg9Cz0L7Qu9GM0L3QuNC6Iik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0JrQvtC+0YDQtNC40L3QsNGC0Ys6Iik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiKHgxO3kxKToiICsgIigiICsgeCArICI7IiArIHkgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4Mjt5Mik6IiArICIoIiArIHgyICsgIjsiICsgeTIgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4Mzt5Myk6IiArICIoIiArIHgzICsgIjsiICsgeTMgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4NDt5NCk6IiArICIoIiArIHg0ICsgIjsiICsgeTQgKyAiKSIpOwogICAgIH0KCiAgICAgdm9pZCBtb3ZlKCkgewogICAgICAgICBTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCh0LTQstC40L3Rg9GC0Ywg0YTQuNCz0YPRgNGDIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoItCf0L4g0L7RgdC4IFg6ICIpOwogICAgICAgICBpbnQgdCA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCLQn9C+INC+0YHQuCBZOiAiKTsKICAgICAgICAgaW50IHQyID0gc2Nhbm5lci5uZXh0SW50KCk7CiAgICAgICAgIHggPSB4ICsgdDsKICAgICAgICAgeDIgPSB4MiArIHQ7CiAgICAgICAgIHgzID0geDMgKyB0OwogICAgICAgICB4NCA9IHg0ICsgdDsKICAgICAgICAgeSA9IHkgKyB0MjsKICAgICAgICAgeTIgPSB5MiArIHQyOwogICAgICAgICB5MyA9IHkzICsgdDI7CiAgICAgICAgIHk0ID0geTQgKyB0MjsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQndC+0LLRi9C1INC60L7QvtGA0LTQuNC90LDRgtGLINGE0LjQs9GD0YDRizogIik7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiKHgxO3kxKToiICsgIigiICsgeCArICI7IiArIHkgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4Mjt5Mik6IiArICIoIiArIHgyICsgIjsiICsgeTIgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4Mzt5Myk6IiArICIoIiArIHgzICsgIjsiICsgeTMgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIih4NDt5NCk6IiArICIoIiArIHg0ICsgIjsiICsgeTQgKyAiKSIpOwogICAgIH0KIH0KIGNsYXNzIENpcmNsZSBleHRlbmRzIEZpZ3VyZSB7CiAgICAgaW50IHI7CgogICAgIENpcmNsZShpbnQgazEsIGludCBsMSwgaW50IHUpIHsKICAgICAgICAgY291bnQrKzsKICAgICAgICAgc3VwZXIueCA9IGsxOwogICAgICAgICBzdXBlci55ID0gbDE7CiAgICAgICAgIHIgPSB1OwogICAgIH0KCiAgICAgdm9pZCBkcmF3KCkgewoKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQmtGA0YPQsyIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCa0L7QvtGA0LTQuNC90LDRgtGLOiIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCm0LXQvdGC0YAgKHg7eSk6IiArICIoIiArIHggKyAiOyIgKyB5ICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQktC10YDRhdC90Y/RjyDRgtC+0YfQutCwOiAiICsgIigiICsgeCArICI7IiArICh5ICsgcikgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCb0LXQstCw0Y8g0YLQvtGH0LrQsDogIiArICIoIiArICh4IC0gcikgKyAiOyIgKyB5ICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQndC40LbQvdGP0Y8g0YLQvtGH0LrQsDogIiArICIoIiArIHggKyAiOyIgKyAoeSAtIHIpICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQn9GA0LDQstCw0Y8g0YLQvtGH0LrQsDogIiArICIoIiArICh4ICsgcikgKyAiOyIgKyB5ICsgIikiKTsKICAgICB9CgogICAgIHZvaWQgbW92ZSgpIHsKICAgICAgICAgU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQodC00LLQuNC90YPRgtGMINGE0LjQs9GD0YDRgyIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50KCLQn9C+INC+0YHQuCBYOiAiKTsKICAgICAgICAgaW50IHQgPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludCgi0J/QviDQvtGB0LggWTogIik7CiAgICAgICAgIGludCB0MiA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgICB4ID0geCArIHQ7CiAgICAgICAgIHkgPSB5ICsgdDI7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigi0J3QvtCy0YvQtSDQutC+0L7RgNC00LjQvdCw0YLRiyDRhNC40LPRg9GA0Ys6ICIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCm0LXQvdGC0YAgKHg7eSk6IiArICIoIiArIHggKyAiOyIgKyB5ICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQktC10YDRhdC90Y/RjyDRgtC+0YfQutCwOiAiICsgIigiICsgeCArICI7IiArICh5ICsgcikgKyAiKSIpOwogICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oItCb0LXQstCw0Y8g0YLQvtGH0LrQsDogIiArICIoIiArICh4IC0gcikgKyAiOyIgKyB5ICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQndC40LbQvdGP0Y8g0YLQvtGH0LrQsDogIiArICIoIiArIHggKyAiOyIgKyAoeSAtIHIpICsgIikiKTsKICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLQn9GA0LDQstCw0Y8g0YLQvtGH0LrQsDogIiArICIoIiArICh4ICsgcikgKyAiOyIgKyB5ICsgIikiKTsKICAgICB9CiB9CiBjbGFzcyBDb21wb3NpdGVGaWd1cmUgZXh0ZW5kcyBGaWd1cmUgewoKICAgICBDb21wb3NpdGVGaWd1cmUoKSB7CgogICAgICAgICBGaWd1cmVbXSBmaWd1cmVzID0gbmV3IEZpZ3VyZVszXTsKICAgICAgICAgICAgIGZpZ3VyZXNbMF0gPSBuZXcgTGluZSgxLCAxLCA1LCA1KTsKICAgICAgICAgICAgIGZpZ3VyZXNbMV0gPSBuZXcgUmVjdGFuZ2xlKDEsIDEsIDQsIDUpOwogICAgICAgICAgICAgZmlndXJlc1syXSA9IG5ldyBDaXJjbGUoMSwgNCwgNSk7CiAgICAgICAgIH0KCgoKICAgICB2b2lkIGRyYXcoKSB7CiAgICAgfQoKICAgICB2b2lkIG1vdmUoKSB7CiAgICAgfQogfQoKIGNsYXNzIEFjdGl2aXR5IHsKICAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgIExpbmUgbGluZSA9IG5ldyBMaW5lKDEsIDEsIDQsIDIpOwogICAgICAgICBDaXJjbGUgY2lyY2xlID0gbmV3IENpcmNsZSgwLCAwLCAyKTsKICAgICAgICAgUmVjdGFuZ2xlIHJlY3RhbmdsZSA9IG5ldyBSZWN0YW5nbGUoMywgMywgNCwgNik7CiAgICAgICAgIEZpZ3VyZVtdIGZpZ3VyZXMgPSBuZXcgRmlndXJlWzNdOwoKICAgICAgICAgbGluZS5kcmF3KCk7CgogICAgICAgICByZWN0YW5nbGUuZHJhdygpOwoKICAgICAgICAgY2lyY2xlLmRyYXcoKTsKICAgICAgICAgCiAgICAgICAgIGZpZ3VyZXNbMF0gPSBsaW5lOwogICAgICAgICBmaWd1cmVzWzFdID0gY2lyY2xlOwogICAgICAgICBmaWd1cmVzWzJdID0gcmVjdGFuZ2xlOwoKICAgICAgICAgZm9yKGludCBuID0gMDsgbiA8IDM7IG4rKykKICAgICAgICAgCWZpZ3VyZXNbbl0uZHJhdygpOwoKICAgICAgICAgU3lzdGVtLm91dC5wcmludChGaWd1cmUuZ2V0Q291bnQoKSk7CiAgICAgfQogfQo=