fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. public class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. Figure figurs[]=new Figure[3];
  9. figurs[0] = new Circle(1,1,1.5);
  10. figurs[1] = new Quadrate(1,1,3,3);
  11. figurs[2] = new Segment(0,0,1,0);
  12. for(Figure i: figurs){
  13. System.out.println(i.getSquare());
  14. }
  15.  
  16. }
  17. }
  18. abstract class Figure{
  19. abstract public double getSquare();
  20. }
  21. class Circle extends Figure{
  22. private double x,y,r;
  23. public Circle(double x,double y,double r){
  24. this.x=x;
  25. this.y=y;
  26. this.r=r;
  27. }
  28. @Override
  29. public double getSquare(){
  30. return Math.PI*r*r;
  31. }
  32. }
  33. class Quadrate extends Figure{
  34. private double x,y,x1,y1;
  35. public Quadrate(double x,double y,double x1,double y1){
  36. this.x=x;
  37. this.y=y;
  38. this.x1=x1;
  39. this.y1=y1;
  40. }
  41. @Override
  42. public double getSquare(){
  43. return Math.abs(x-x1)*Math.abs(y-y1);
  44. }
  45. }
  46. class Segment extends Figure{
  47. private double x,y,x1,y1;
  48. public Segment(double x,double y,double x1,double y1){
  49. this.x=x;
  50. this.y=y;
  51. this.x1=x1;
  52. this.y1=y1;
  53. }
  54. @Override
  55. public double getSquare(){
  56. return 0;
  57. //площадь отрезка всегда 0
  58. }
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Mozart Compiler 1.4.0 (20080704) playing Oz 3

%%% feeding file prog.oz

%*************************** parse error ************************
%**
%** syntax error, unexpected T_OZATOM, expecting T_ENDOFFILE
%**
%** in file "./prog.oz", line 1, column 7
%** ------------------ rejected (1 error)
stdout
Standard output is empty