// TODO 04c - add a method initialize the Coin array and populate it with the coin type info public void InitializeCoinArray() { _coins = new Coin[3]; _coins[0] = new Coin() { Name = Coin.TypeName.SmallGoldCoin, Description = "Gold coin with the Kings's face on one side and the Castle Wilhelm on the other side.", ValueInDollars = 10, CountInGameInventory = 50 }; _coins[1] = new Coin() { Name = Coin.TypeName.SmallSilverCoin, Description = "Silver coin with the Queen's face on one side and the River Thomes on the other side.", ValueInDollars = 5, CountInGameInventory = 100 }; _coins[2] = new Coin() { Name = Coin.TypeName.SmallBronzeCoin, Description = "Bronze coin with the Prince's face on one side and Mount Fidoria on the other side.", ValueInDollars = 1, CountInGameInventory = 500 }; }
// TODO 10a - add a method to add coins to the player's treasure /// <summary> /// add coins to the player inventory /// </summary> /// <param name="gameTreasure">Treasure object</param> /// <param name="quantity">quantity of the coin to add</param> /// <param name="coinType">enum - TypeName of the coin to add</param> public static void AddCoinsToPlayer(Treasure gameTreasure, int quantity, Coin.TypeName coinType) { foreach (Coin coin in gameTreasure.Coins) { if (coin.Name == coinType) { coin.CountInPlayerInventory += quantity; } } }
/// <summary> /// add coins to the player inventory /// </summary> /// <param name="myPlayer">Player object</param> /// <param name="gameTreasure">Treasure object</param> /// <param name="quantity">quantity of the coin to add</param> /// <param name="coinType">enum - TypeName of the coin to add</param> public static void AddCoinsToPlayer(Player myPlayer, Treasure gameTreasure, int quantity, Coin.TypeName coinType) { }
/// <summary> /// subrtract coins from the player inventory /// </summary> /// <param name="myPlayer">Player object</param> /// <param name="gameTreasure">Treasure object</param> /// <param name="quantity">quantity of the coin to subrtract</param> /// <param name="coinType">enum - TypeName of the coin to subrtract</param> public static void SubtractCoinsFromPlayer(Player myPlayer, Treasure gameTreasure, int quantity, Coin.TypeName coinType) { }
// TODO 11a - add a method to subtract coins from the player's treasure /// <summary> /// subrtract coins from the player inventory /// </summary> /// <param name="gameTreasure">Treasure object</param> /// <param name="quantity">quantity of the coin to subrtract</param> /// <param name="coinType">enum - TypeName of the coin to subrtract</param> public static void SubtractCoinsFromPlayer(Treasure gameTreasure, int quantity, Coin.TypeName coinType) { foreach (Coin coin in gameTreasure.Coins) { if (coin.Name == coinType) { coin.CountInPlayerInventory -= quantity; } } }