static void PrintInfo(object obj) { /* if (obj is ISocializable ) * { * ISocializable iso = (ISocializable)obj; * iso.depart(); * iso.wish(); * return; * } */ if (obj is ISocializable && obj is IEmotionable) { ISocializable iso = (ISocializable)obj; IEmotionable imo = (IEmotionable)obj; iso.depart(); iso.wish(); imo.cry(); imo.laugh(); return; } if (obj is IEmotionable && !(obj is ISocializable)) { IEmotionable imo = (IEmotionable)obj; imo.cry(); imo.laugh(); return; } }
private static void atTheParty(IEmotionable e, ISocializable s) { Console.WriteLine("\nAt The Party : "); e.cry(); e.laugh(); s.wish(); s.depart(); }
private static void atTheMovie(IEmotionable e) { Console.WriteLine("\nAt The Movie : "); e.cry(); e.laugh(); }
public static void atTheMovie(IEmotionable obj) { Console.WriteLine("\nAt the Movie"); obj.cry(); obj.laugh(); }