コード例 #1
0
        public static void Run()
        {
            Console.WriteLine("Let's create a house");
            House house = new House();

            Console.Write("Enter length: ");
            house.Length = double.Parse(Console.ReadLine());
            Console.Write("Enter width: ");
            house.Width = double.Parse(Console.ReadLine());
            Console.Write("Enter height: ");
            house.Height = double.Parse(Console.ReadLine());

            Console.WriteLine(BuildingProgram.DescribeBuilding(house));
            Console.WriteLine();

            Console.WriteLine("Let's create a pyramid");
            Pyramid pyramid = new Pyramid();

            Console.Write("Enter length: ");
            pyramid.Length = double.Parse(Console.ReadLine());
            Console.Write("Enter width: ");
            pyramid.Width = double.Parse(Console.ReadLine());
            Console.Write("Enter height: ");
            pyramid.Height = double.Parse(Console.ReadLine());

            Console.WriteLine(BuildingProgram.DescribeBuilding(pyramid));
            Console.WriteLine();

            Console.WriteLine("Let's create the Great Pyramid");
            var greatPyramid = BuildingProgram.BuildGreatPyramid();

            Console.WriteLine($"The great pyramid is {greatPyramid.Length} length, {greatPyramid.Width} width, {greatPyramid.Height} height.");
            Console.WriteLine(BuildingProgram.DescribeBuilding(greatPyramid));
        }
コード例 #2
0
        public static Pyramid BuildGreatPyramid()
        {
            Pyramid pyramid = new Pyramid();

            pyramid.Length = 756;
            pyramid.Width  = 481;
            pyramid.Height = 756;

            return(pyramid);
        }