示例#1
0
 public virtual void HonkOn(IAutomotiveEntity other)
 {
     for (int i = 0; i < HonkCount; i++)
     {
         Console.Beep();
         Console.WriteLine($"{Name} honks on the {other.Name}");
     }
 }
示例#2
0
        public override void HonkOn(IAutomotiveEntity other)
        {
            base.HonkOn(other);

            Console.WriteLine();

            var carInstances = GetInstances <Car>();

            foreach (var car in carInstances)
            {
                Console.WriteLine(car.ToString());
            }
            Console.WriteLine();
            var truckInstances = GetInstances <Truck>();

            foreach (var truck in truckInstances)
            {
                Console.WriteLine(truck.ToString());
            }
        }