コード例 #1
0
ファイル: TestShapeHierarchy.cs プロジェクト: stefonii/CSC253
        static void Main(string[] args)
        {
            TwoDimShape[] myShapes = new TwoDimShape[3];
            myShapes[0] = new Rectangle(10, 5);
            myShapes[1] = new Triangle(12, 6);
            myShapes[2] = new Circle(8);

            foreach (TwoDimShape tds in myShapes)
            {
                ProcessShape(tds);
                Console.WriteLine("");
            }
        }
コード例 #2
0
ファイル: TestShapeHierarchy.cs プロジェクト: stefonii/CSC253
 // static method processShape
 public static void ProcessShape(TwoDimShape obj)
 {
     Console.Write($"Area = {obj.Area()}");
 }