//CONSTRUCTORS public MonsterList () { for(int i = 0; i < 13; i++) { Monster monster = new Monster (); AddMonster (monster); } }
//METHODS public void AddMonster(Monster m) { allMonsters.Add(m); }
static void MonsterInfo(Monster monster) { DisplayScreenHeader($"\tName: {monster.Name}"); DisplayScreenHeader($"\tAge: {monster.Age}"); DisplayScreenHeader($"\tAttitude: {monster.Attitude}"); }
static void MonsterInfo(Monster monster) { Console.WriteLine($"\tName: {monster.Name}"); Console.WriteLine($"\tAge: {monster.Age}"); Console.WriteLine($"\tAttitude: {monster.Attitude}"); }
static void DisplayUpdateMonster(List <Monster> monsters) { bool validResponse = false; Monster selectedMonster = null; do { DisplayScreenHeader("Update Monster"); // // display all monster names // Console.WriteLine("\tMonster Names"); Console.WriteLine("\t-------------"); foreach (Monster monster in monsters) { Console.WriteLine("\t" + monster.Name); } // // get user monster choice // Console.WriteLine(); Console.Write("\tEnter name:"); string monsterName = Console.ReadLine(); // // get monster object // foreach (Monster monster in monsters) { if (monster.Name == monsterName) { selectedMonster = monster; validResponse = true; break; } } // // feedback for wrong name choice // if (!validResponse) { Console.WriteLine("\tPlease select a correct name."); DisplayContinuePrompt(); } // // update monster // } while (!validResponse); // // updata monster // string userResponse; Console.WriteLine("\tReading to update. Press enter to keep the current info."); Console.Write($"\tCurrent Name: {selectedMonster.Name} New Name: "); userResponse = Console.ReadLine(); if (userResponse != "") { selectedMonster.Name = userResponse; } Console.Write($"\tCurrent Age: {selectedMonster.Age} New Age: "); userResponse = Console.ReadLine(); if (userResponse != "") { int.TryParse(userResponse, out int age); selectedMonster.Age = age; } Console.Write($"\tCurrent Attitude: {selectedMonster.Attitude} New Attitude: "); userResponse = Console.ReadLine(); if (userResponse != "") { Enum.TryParse(userResponse, out Monster.EmotionalState attitude); selectedMonster.Attitude = attitude; } DisplayContinuePrompt(); }
//METHODS public bool AttackMonster(Monster m) { bool monsterDead = false; m.Health = m.Health - damage; this.health = this.health - m.Attack; if(m.Health <= 0) { monstersKilled++; return monsterDead = true; } else { return monsterDead; } }
//METHODS public void AddMonster(Monster m) { allMonsters.Add (m); }