回覆列表
  • 1 # 錢布斯

    // Point類

    public class Point

    {

    private int x;

    private int y;

    public Point(int x, int y)

    {

    this.x = x;

    this.y = y;

    }

    public int X

    {

    get{ return x;}

    set{ x = value;}

    }

    public int Y

    {

    get{ return y;}

    set{ y = value;}

    }

    }

    // Circle類, 繼承Point類作為圓心

    public class Circle : Point

    {

    float r; //半徑

    public Circle(int x, int y, float r):base(x, y)

    {

    this.r = r;

    }

    // 獲取或設定圓心

    public Point Center

    {

    get { return this;}

    set

    {

    this.X = value.X;

    this.Y = value.Y;

    }

    }

    // 獲取或設定半徑

    public float Radius

    {

    get{ return r;}

    set { r = value;}

    }

    // 其他屬性、方法……

    }

  • 2 # 錢布斯

    // Point類

    public class Point

    {

    private int x;

    private int y;

    public Point(int x, int y)

    {

    this.x = x;

    this.y = y;

    }

    public int X

    {

    get{ return x;}

    set{ x = value;}

    }

    public int Y

    {

    get{ return y;}

    set{ y = value;}

    }

    }

    // Circle類, 繼承Point類作為圓心

    public class Circle : Point

    {

    float r; //半徑

    public Circle(int x, int y, float r):base(x, y)

    {

    this.r = r;

    }

    // 獲取或設定圓心

    public Point Center

    {

    get { return this;}

    set

    {

    this.X = value.X;

    this.Y = value.Y;

    }

    }

    // 獲取或設定半徑

    public float Radius

    {

    get{ return r;}

    set { r = value;}

    }

    // 其他屬性、方法……

    }

  • 中秋節和大豐收的關聯?
  • 網路直銷適合農民做嗎?