fork download
  1. import java.awt.*;
  2. import java.util.Scanner;
  3.  
  4. abstract class Figure {
  5. protected int x;
  6. protected int y;
  7. public static int count;
  8. public static int Count(){
  9. return count;
  10.  
  11. }
  12.  
  13. public int getX() {
  14. return x;
  15. }
  16.  
  17. public int getY() {
  18. return y;
  19. }
  20.  
  21. public void setX(int x) {
  22. this.x = x;
  23. }
  24.  
  25. public void setY(int y) {
  26. this.y = y;
  27. }
  28.  
  29. abstract void draw();
  30.  
  31. abstract void move();
  32. }
  33.  
  34. class Line extends Figure {
  35. int x2;
  36. int y2;
  37.  
  38.  
  39. Line(int k1, int l1, int k2, int l2) {
  40. count++;
  41. super.x = k1;
  42. super.y = l1;
  43. x2 = k2;
  44. y2 = l2;
  45.  
  46.  
  47. }
  48. void draw() {
  49. System.out.println("Линия");
  50. System.out.println("Координаты:");
  51. System.out.println("(x1;y1):" + "(" + x + ";" + y + ")");
  52. System.out.println("(x2;y2):" + "(" + x2 + ";" + y2 + ")");
  53. }
  54.  
  55. void move() {
  56. Scanner scanner = new Scanner(System.in);
  57. System.out.println("Сдвинуть фигуру");
  58. System.out.print("По оси X: ");
  59. int t = scanner.nextInt();
  60. System.out.print("По оси Y: ");
  61. int t2 = scanner.nextInt();
  62. x = x + t;
  63. x2 = x2 + t;
  64. y = y + t2;
  65. y2 = y2 + t2;
  66. System.out.println("Новые координаты фигуры: ");
  67. System.out.println("(x1;y1):" + "(" + x + ";" + y + ")");
  68. System.out.println("(x2;y2):" + "(" + x2 + ";" + y2 + ")");
  69. }
  70. }
  71. class Rectangle extends Figure {
  72.  
  73. int x2;
  74. int y2;
  75. int x3;
  76. int y3;
  77. int x4;
  78. int y4;
  79.  
  80. Rectangle(int k1, int l1, int l2, int k3) {
  81. count++;
  82. super.x = k1;
  83. super.y = l1;
  84. x2 = x;
  85. y2 = l2;
  86. x3 = k3;
  87. y3 = y;
  88. x4 = x3;
  89. y4 = y2;
  90. }
  91.  
  92. void draw() {
  93.  
  94. System.out.println("Прямоугольник");
  95. System.out.println("Координаты:");
  96. System.out.println("(x1;y1):" + "(" + x + ";" + y + ")");
  97. System.out.println("(x2;y2):" + "(" + x2 + ";" + y2 + ")");
  98. System.out.println("(x3;y3):" + "(" + x3 + ";" + y3 + ")");
  99. System.out.println("(x4;y4):" + "(" + x4 + ";" + y4 + ")");
  100. }
  101.  
  102. void move() {
  103. Scanner scanner = new Scanner(System.in);
  104. System.out.println("Сдвинуть фигуру");
  105. System.out.print("По оси X: ");
  106. int t = scanner.nextInt();
  107. System.out.print("По оси Y: ");
  108. int t2 = scanner.nextInt();
  109. x = x + t;
  110. x2 = x2 + t;
  111. x3 = x3 + t;
  112. x4 = x4 + t;
  113. y = y + t2;
  114. y2 = y2 + t2;
  115. y3 = y3 + t2;
  116. y4 = y4 + t2;
  117. System.out.println("Новые координаты фигуры: ");
  118. System.out.println("(x1;y1):" + "(" + x + ";" + y + ")");
  119. System.out.println("(x2;y2):" + "(" + x2 + ";" + y2 + ")");
  120. System.out.println("(x3;y3):" + "(" + x3 + ";" + y3 + ")");
  121. System.out.println("(x4;y4):" + "(" + x4 + ";" + y4 + ")");
  122. }
  123. }
  124. class Circle extends Figure {
  125. int r;
  126.  
  127. Circle(int k1, int l1, int u) {
  128. count++;
  129. super.x = k1;
  130. super.y = l1;
  131. r = u;
  132. }
  133.  
  134. void draw() {
  135.  
  136. System.out.println("Круг");
  137. System.out.println("Координаты:");
  138. System.out.println("Центр (x;y):" + "(" + x + ";" + y + ")");
  139. System.out.println("Верхняя точка: " + "(" + x + ";" + (y + r) + ")");
  140. System.out.println("Левая точка: " + "(" + (x - r) + ";" + y + ")");
  141. System.out.println("Нижняя точка: " + "(" + x + ";" + (y - r) + ")");
  142. System.out.println("Правая точка: " + "(" + (x + r) + ";" + y + ")");
  143. }
  144.  
  145. void move() {
  146. Scanner scanner = new Scanner(System.in);
  147. System.out.println("Сдвинуть фигуру");
  148. System.out.print("По оси X: ");
  149. int t = scanner.nextInt();
  150. System.out.print("По оси Y: ");
  151. int t2 = scanner.nextInt();
  152. x = x + t;
  153. y = y + t2;
  154. System.out.println("Новые координаты фигуры: ");
  155. System.out.println("Центр (x;y):" + "(" + x + ";" + y + ")");
  156. System.out.println("Верхняя точка: " + "(" + x + ";" + (y + r) + ")");
  157. System.out.println("Левая точка: " + "(" + (x - r) + ";" + y + ")");
  158. System.out.println("Нижняя точка: " + "(" + x + ";" + (y - r) + ")");
  159. System.out.println("Правая точка: " + "(" + (x + r) + ";" + y + ")");
  160. }
  161. }
  162. class CompositeFigure extends Figure {
  163. int[] intAry = new int[10];
  164. Figure []Array = new Figure[]{
  165. new Line(1, 1, 2, 2),
  166. new Rectangle(1, 1, 4, 5),
  167. new Circle(2, 2, 4),
  168. };
  169. CompositeFigure(int i) {
  170. Figure Composite[] = new Figure[4];
  171. Composite[0] = new Line(1, 0, 3, 4);
  172. Composite[1] = new Line(5, 7, 9, 9);
  173. Composite[2] = new Rectangle(3, 3, 4, 6);
  174. Composite[3] = new Circle(0, 0, 2);
  175. }
  176.  
  177. void draw() { //Что делать с этими методами?
  178. }
  179.  
  180. void move() {
  181. }
  182. }
  183.  
  184. class Activity {
  185. public static void main(String[] args) {
  186. Line line = new Line(1, 1, 4, 2);
  187. Circle circle = new Circle(0, 0, 2);
  188. Rectangle rectangle = new Rectangle(3, 3, 4, 6);
  189.  
  190. line.draw();
  191. line.move();
  192.  
  193. rectangle.draw();
  194. rectangle.move();
  195.  
  196. circle.draw();
  197. circle.move();
  198.  
  199. //CompositeFigure.draw(); //Как здесь?
  200.  
  201. System.out.print(Count()); //Как здесь?
  202.  
  203. }
  204. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:201: error: cannot find symbol
         System.out.print(Count()); //??? ??????
                          ^
  symbol:   method Count()
  location: class Activity
1 error
stdout
Standard output is empty