Beispiel #1
0
 public void TestPunterCreation()
 {
     //testing the Factory not creating the instances that are not defined
     //if you don't give proper name based on the defined classes, no instance will be created
     RunGame.PunterAbstract result = PunterFactory.CreatePunter("John");
     Assert.AreEqual(null, result);
 }
Beispiel #2
0
        public static PunterAbstract CreatePunter(String name)
        {
            Count++;

            PunterAbstract punter = null;

            if (name == "Robert")
            {
                punter = new Robert(50, false);
                return(punter);
            }
            else if (name == "Samuel")
            {
                punter = new Samuel(50, false);
                return(punter);
            }
            else if (name == "George")
            {
                punter = new George(50, false);
                return(punter);
            }
            return(null);
        }