Beispiel #1
0
        public static void SwimmerTest(String[] args)
        {
            Swimmer johan  = new Swimmer("Johan");
            Swimmer magnus = new Swimmer("Magnus", new BathingSuit());

            johan.SetSuit(new BathingSuit());
            magnus.SetSuit(null);
            ProfessionalSwimmer eric  = new ProfessionalSwimmer("Eric", new BathingSuit());
            ProfessionalSwimmer simon = new ProfessionalSwimmer("Simon", new BathingSuit());

            eric.SetSuit(null);
            List <Swimmer> swimmers = new List <Swimmer>();

            swimmers.Add(johan);
            swimmers.Add(new YoungSwimmer("Christoffer", new BathingSuit()));
            swimmers.Add(new YoungSwimmer("Christoffer", null));
            foreach (Swimmer sw in swimmers)
            {
                Console.WriteLine(sw.Swim());
            }
            foreach (Swimmer sw in swimmers)
            {
                Console.WriteLine(sw.Swim());
            }
            Console.ReadKey();
        }
Beispiel #2
0
        public static void BubblePoolTest(String[] args)
        {
            BubblePool newPool = new BubblePool(5);
            Swimmer    johan   = new Swimmer("Johan");

            for (int i = 4; (i > 0); i--)
            {
                newPool.GetIn(new Swimmer("Johan"));
            }
            try
            {
                newPool.GetIn(johan);
                // här kastas PoolDirtyException.
            }
            catch
            {
                Console.WriteLine("All swimmers has to leave the pool!");
                newPool.Clean();
            }
            newPool.GetIn(johan);
            newPool.GetIn(new Swimmer("Johan"));
            // detta borde alltså inte vara något problem längre.
            Console.ReadKey();
        }
Beispiel #3
0
 public virtual void GetOut(Swimmer leaver)
 {
     this.people.Remove(leaver);
     this.GetDirtier();
 }
Beispiel #4
0
 public virtual void GetIn(Swimmer joiner)
 {
     this.people.Add(joiner);
     this.GetDirtier();
 }
Beispiel #5
0
 public override void GetIn(Swimmer joiner)
 {
 }