[ create a new paste ] login | about

Link: http://codepad.org/WIRDgCnW    [ raw code | output | fork ]

C, pasted on May 24:
    class Shape
    {
    private double x, y, z;
     
    public Shape()
    {
    this(0.0, 0.0, 0.0);
    }
     
    public Shape(double x, double y, double z)
    {
    this.x = x;
    this.y = y;
    this.z = z;
    }
     
    public void show()
    {
    System.out.println("中心座標: (" + x + "," + y + "," + z + ")");
    }
     
    public void move(double dx, double dy, double dz)
    {
    x += dx;
    y += dy;
    z += dz;
    }
     
    public void scale(double k)
    {
    x *= k;
    y *= k;
    z *= k;
    }
    }
     
    class Sphere extends Shape
    {
    private double radius = 0.0;
     
    public Sphere()
    {
    super();
    }
     
    public Sphere(double x, double y, double z)
    {
    super(x, y, z);
    }
     
    @Override
    public void show()
    {
    super.show();
    System.out.println("半径:" + radius);
    }
     
    @Override
    public void scale(double k)
    {
    super.scale(k);
    }
    }
     
    class ShapeEx
    {
    public static void main (String[] args)
    {
    Shape[] shapes = new Shape[4];
     
    shapes[0] = new Shape();
    shapes[1] = new Shape(1.1, 2.2, 3.3);
    shapes[2] = new Sphere();
    shapes[3] = new Sphere(4.4, 5.5, 6.6);
     
    for (Shape shape : shapes)
    {
    shape.show();
    shape.move(1.0, 1.0, 1.0);
    shape.show();
    shape.scale(2.0);
    shape.show();
    }
    }
    }


Output:
1
2
3
4
5
Line 1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Shape'
Line 37: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Sphere'
Line 51: error: stray '@' in program
Line 58: error: stray '@' in program
Line 65: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ShapeEx'


Create a new paste based on this one


Comments: