1.用C#写一个表示盒子的类,要包含算体积的方法 2.另外写一个表示彩色盒子的类继承1题中的盒子类

1个回答

  • 盒子类:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    namespace ClassLibrary1

    {

    public class Case

    {

    private double length;

    public double Length

    {

    get { return length; }

    set { length = value; }

    }

    private double width;

    public double Width

    {

    get { return width; }

    set { width = value; }

    }

    private double height;

    public double Height

    {

    get { return height; }

    set { height = value; }

    }

    public double TotalArea()

    {

    return Height * Width * Length;

    }

    }

    }

    彩色盒子类继承盒子类:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    namespace ClassLibrary1

    {

    class ChromaticCase:Case

    {

    }

    }