static void Main(string[] args) { Square s = new Square(); s.Print(); int a = s.GetNumberOfSides(); Rectangle r = new Rectangle(); r.Draw(); r.Print(); r.GetNumberOfSides(); }
static void Multis() { Console.ForegroundColor = ConsoleColor.Green; Rectangle rec = new Rectangle(); (rec as IDrawable).Draw(); (rec as IPrintable).Draw(); rec.Print(); Console.WriteLine($"Rectangle: Number of sides {rec.GetNumberOfSides()}"); Console.ForegroundColor = ConsoleColor.Yellow; Square squ = new Square(); (squ as IDrawable).Draw(); (squ as IPrintable).Draw(); squ.Print(); Console.WriteLine($"Square: Number of sides {squ.GetNumberOfSides()}"); }
static void Main(string[] args) { Console.WriteLine("***** MI Interface Hierarchy *****\n"); Square mySquare = new Square(); IPrintable t = (IPrintable)mySquare; t.Draw(); IDrawable p = (IDrawable)mySquare; p.Draw(); mySquare.Print(); Console.WriteLine(mySquare.GetNumberOfSides()); Console.WriteLine("\n"); Rectangle Rec = new Rectangle(); Rec.GetNumberOfSides(); Rec.Draw(); Rec.Print(); Console.WriteLine(Rec.GetNumberOfSides()); Console.ReadLine(); }