/// <summary> /// Implements the action when a player lands on this square. /// Credits the lottery win and advances a square. /// </summary> /// <param name="player">who landed on the square</param> public override void LandOn(Player player) { base.LandOn(player); // leave in for possible future change player.Credit(AMOUNT_TO_BE_CREDITED); player.Location = player.Location.NextSquare; }
/// <summary> /// Implements the action when a player lands on this square. /// Debits the bad investment. /// </summary> /// <param name="player">who landed on the square</param> public override void LandOn(Player player) { base.LandOn(player); // keep in case of future change player.Debit(AMOUNT_TO_BE_DEBITED); }
/// <summary> /// Performs the necessary action when a player lands on this type of square. /// /// Landing on an ordinary square has /// no consequential action to be performed at this time. /// /// Pre: the player who lands on this square /// Post: none. /// </summary> /// <param name="player">who landed on this square</param> /// <remarks>Virtual method</remarks> public virtual void LandOn(Player player) { // This method is implemented within subclasses of Square // perhaps something will be done in a future version of this game // for an Ordinary square switch (player.Location.Name) { case "Lottery Win": player.Credit(10); player.Location = NextSquare; break; case "Bad Investment": player.Debit(25); break; default: break; } }
/// <summary> /// Performs the necessary action when a player lands on this type of square. /// /// Landing on an ordinary square has /// no consequential action to be performed at this time. /// /// Pre: the player who lands on this square /// Post: none. /// </summary> /// <param name="player">who landed on this square</param> /// <remarks>Virtual method</remarks> public virtual void LandOn(Player player) { // This method is implemented within subclasses of Square // perhaps something will be done in a future version of this game // for an Ordinary square }
//################## Game Play Methods above this line /// <summary> /// This method demonstrate how the WriteLine of ListBoxTraceListener can be used /// to output to the ListBox for debugging purposes. /// /// Outputs a player's current location and amount of money /// to /// pre: player's object to display /// post: displayed the player's location and amount /// </summary> /// <param name="who">the player to display</param> public static void OutputIndividualDetails(Player who) { Trace.WriteLine(String.Format("Player {0} is on square {1} with {2:c}", who.Name, who.Location.Number, who.Money)); }
/// <summary> /// Initialises each of the players and adds them to the players BindingList. /// This method is to be called only once, when the game first starts. /// /// Pre: none. /// Post: the game's players are initialised. /// </summary> public void InitialiseAllThePlayers() { //clear all the players Players.Clear(); for (int playerNumber = 0; playerNumber < NumberOfPlayers; playerNumber++) { //change all the player's name back to the default name, and back to start square Player player = new Player(defaultNames[playerNumber], board.StartSquare); player.PlayerTokenColour = playerTokenColours[playerNumber]; Players.Add(player); } }
/// <summary> /// Initialises each of the players and adds them to the players BindingList. /// This method is to be called only once, when the game first starts. /// /// Pre: none. /// Post: the game's players are initialised. /// </summary> public void InitialiseAllThePlayers() { players.Clear(); for (int i = 0; i < numberOfPlayers; i++) { Player player = new Player(); player.Money = 100; player.Name = defaultNames[i]; player.PlayerTokenColour = playerTokenColours[i]; player.Location = board.Squares[0]; players.Add(player); } }
/// <summary> /// Implements the action when a player lands on this square. /// Debits the bad investment. /// </summary> /// <param name="player">who landed on the square</param> public override void LandOn(Player player) { base.LandOn(player); player.Debit(AMOUNT_TO_BE_DEBITED); }
/// <summary> /// Implements the action when a player lands on this square. /// Credits the lottery win and advances a square. /// </summary> /// <param name="player">who landed on the square</param> public override void LandOn(Player player) { base.LandOn(player); player.Credit(AMOUNT_TO_BE_CREDITED); }
/// <summary> /// Performs the necessary action when a player lands on this type of square. /// /// Landing on an ordinary square has /// no consequential action to be performed at this time. /// /// Pre: the player who lands on this square /// Post: none. /// </summary> /// <param name="player">who landed on this square</param> /// <remarks>Virtual method</remarks> public virtual void LandOn(Player player) { // This method is implemented within subclasses of Square }
/// <summary> /// Initialises each of the players and adds them to the players BindingList. /// This method is called only once, when the game first startsfrom HareAndTortoiseForm. /// /// Pre: none. /// Post: all the game's players are initialised. /// </summary> public static void InitialiseAllThePlayers() { //##################### Code needs to be added here. ############################################################ for (int i = 0; i < numberOfPlayers; i++) { Player player = new Player(defaultNames[i], Board.StartSquare); player.PlayerTokenColour = playerTokenColours[i]; player.Money = 100; players.Add(player); } }