private static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Gang of Four Design Pattern - Composite"); // Creating leaf nodes in the tree var ally = new MonsterHunter {FirstName = "Ally", LastName = "Jones"}; var cory = new MonsterHunter {FirstName = "Cory", LastName = "Olsen"}; var gluck = new MonsterHunter {FirstName = "Jen", LastName = "Gluck"}; var janet = new MonsterHunter {FirstName = "Janet", LastName = "Smith"}; var jennifer = new MonsterHunter {FirstName = "Jen", LastName = "Parker"}; var john = new MonsterHunter {FirstName = "John", LastName = "Olsen"}; var matt = new MonsterHunter {FirstName = "Matt", LastName = "Parker"}; var pete = new MonsterHunter {FirstName = "Pete", LastName = "Olsen"}; // Creating groups or branches in the tree var parkers = new MonsterHunterTeam {GroupName = "The Parkers", MonsterHunters = {jennifer, matt}}; var olsenGang = new MonsterHunterTeam {GroupName = "Gaggle of Geese", MonsterHunters = {cory, john, pete, parkers}}; // Creating root composed of leaves and branch nodes var teamA = new MonsterHunterTeam {GroupName = "Team A", MonsterHunters = {olsenGang, ally, gluck, janet}}; teamA.GoldTokens = 1023; Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(teamA.ShowStats()); Console.ReadKey(); }
public void WeaponWithOneDamageKills1HealthMonster() { LaserGun w = new LaserGun("Test Weapon", "Test Weapon", 1); Monster m = new Monster("Test", 1); MonsterHunter mh = new MonsterHunter("First", "Last", w, w); string expected = $"{mh.GetFullName()} hits {m.Name} with {w.Name} and kills it!"; Assert.AreEqual(mh.Attack(m), expected); }
public void AttackMonsterReportsCorrectly() { LaserGun w = new LaserGun("Test Weapon", "Test Weapon", 1); Monster m = new Monster("Test", 10); MonsterHunter mh = new MonsterHunter("First", "Last", w, w); string expected = $"{mh.GetFullName()} hits {m.Name} with {w.Name} doing {w.Damage} damage."; Assert.AreEqual(mh.Attack(m), expected); }
public HttpResponseMessage Add(MonsterHunter hunter) { //if (!ModelState.IsValid) //{ //} return(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("OK") }); }
public MonsterHunter Get() { MonsterHunter mh = new MonsterHunter(); mh.Title = "Aloha Katora"; mh.Age = 100; mh.Magic = 5; mh.Type = HeroType.Mage; mh.Strenght = 1; mh.Life = 3; mh.DefeatedMonsters = new List <Monster>() { new Monster() { FightType = FightType.Magic, Name = "Ghost", Power = 4 } }; return(mh); }
public void CanAttemptCaptureMonster() { LaserGun w = new LaserGun("Test Weapon", "Test Weapon", 1); Monster m = new Monster("Test", 10) { IsElderDragon = false }; MonsterHunter mh = new MonsterHunter("First", "Last", w, "Longsword"); string expected = $"{mh.GetFullName()} attempts to capture {m.Name} ...... and caught it!"; string expected2 = $"{mh.GetFullName()} attempts to capture {m.Name} ...... but it escaped!"; string actual = mh.Capture(m); Assert.That(actual.Equals(expected)); Assert.That(actual.Equals(expected2)); Assert.AreEqual(actual, expected); Assert.AreEqual(actual, expected2); }