public static void TestFunction() { Console.WriteLine("==========抽象工廠模式測試=========="); TrainingCamp trainingCamp = new ArcherTrainingCamp(); Adventurer archer = trainingCamp.trainAdventurer(); trainingCamp = new WarriorTrainingCamp(); Adventurer warrior = trainingCamp.trainAdventurer(); archer.display(); warrior.display(); Console.ReadLine(); }
public static void TestFunction() { Console.WriteLine("==========工廠模式測試=========="); TrainingCamp trainingCamp = new ArcherTrainingCamp(); Adventurer memberA = trainingCamp.trainAdventurer(); trainingCamp = new WarriorTrainingCamp(); Adventurer memberB = trainingCamp.trainAdventurer(); Assert.AreEqual(memberA.getType(), "Archer"); Assert.AreEqual(memberB.getType(), "Warrior"); Console.ReadLine(); }