/// <summary> /// Visits the ticket booth. /// </summary> /// <param name="ticketBooth"> The ticket booth that will be visited.</param> /// <returns> The ticket from the ticket booth.</returns> public Ticket VisitTicketBooth(MoneyCollectingBooth ticketBooth) { // Gets the ticket price and stores it in the amount. decimal amount = ticketBooth.TicketPrice; // Calls the wallet's remove money. decimal removedMoney = this.wallet.RemoveMoney(amount); // Sells the ticket. Ticket ticket = ticketBooth.SellTicket(removedMoney); // Get the water price. decimal waterPrice = ticketBooth.WaterBottlePrice; // Remove money from the wallet. decimal money = this.wallet.RemoveMoney(waterPrice); // Sells the water. WaterBottle waterBottle = ticketBooth.SellWaterBottle(waterPrice); // Add the water bottle to your bag. bag.Add(waterBottle); return(ticket); }
/// <summary> /// Visits the booth to purchase a ticket and a water bottle. /// </summary> /// <param name="ticketBooth">The booth to visit.</param> /// <returns>A purchased ticket.</returns> public Ticket VisitTicketBooth(MoneyCollectingBooth ticketBooth) { if (this.wallet.MoneyBalance < ticketBooth.TicketPrice) { this.WithdrawMoney(ticketBooth.TicketPrice * 2); } // Take ticket money out of wallet. decimal ticketPayment = this.wallet.RemoveMoney(ticketBooth.TicketPrice); // Buy ticket. Ticket ticket = ticketBooth.SellTicket(ticketPayment); if (this.wallet.MoneyBalance < ticketBooth.WaterBottlePrice) { this.WithdrawMoney(ticketBooth.WaterBottlePrice * 2); } // Take water bottle money out of wallet. decimal waterPayment = this.wallet.RemoveMoney(ticketBooth.WaterBottlePrice); // Buy water bottle. WaterBottle bottle = ticketBooth.SellWaterBottle(waterPayment); // Add water bottle to bag. this.bag.Add(bottle); return(ticket); }
/// <summary> /// The guest visits the ticket booth. /// </summary> /// <param name="ticketBooth">The ticket booth to visit.</param> /// <returns>The ticket booth.</returns> public Ticket VisitTicketBooth(MoneyCollectingBooth ticketBooth) { // Gets ticket price from property. decimal ticketPrice = ticketBooth.TicketPrice; // Withdraw twice the amount of the ticket price if necessary. if (this.wallet.MoneyBalance < ticketPrice) { this.WithdrawMoney(ticketPrice * 2); } // Removes money from wallet for ticket. decimal moneyForTicket = this.wallet.RemoveMoney(ticketPrice); // Sells the ticket. Ticket ticket = ticketBooth.SellTicket(moneyForTicket); // Gets price of water bottle. decimal priceWaterBottle = ticketBooth.WaterBottlePrice; // Withdraw twice the amount of the water bottle price if necessary. if (this.wallet.MoneyBalance < priceWaterBottle) { this.WithdrawMoney(priceWaterBottle * 2); } // Removes money for watter bottle. decimal moneyForWaterBottle = this.wallet.RemoveMoney(priceWaterBottle); // Sells the guest a water bottle and adds it to the items list.. WaterBottle waterBottle = ticketBooth.SellWaterBottle(moneyForWaterBottle); this.bag.Add(waterBottle); return(ticket); }
/// <summary> /// Visits a booth to purchase a ticket and other booth items. /// </summary> /// <param name="ticketBooth">The booth to visit.</param> /// <returns>A purchased ticket.</returns> public Ticket VisitTicketBooth(MoneyCollectingBooth ticketBooth) { Ticket result = null; if (this.wallet.MoneyBalance < ticketBooth.TicketPrice) { this.WithdrawMoney(ticketBooth.TicketPrice * 2); } decimal ticketPayment = this.wallet.RemoveMoney(ticketBooth.TicketPrice); result = ticketBooth.SellTicket(ticketPayment); if (this.wallet.MoneyBalance < ticketBooth.WaterBottlePrice) { this.WithdrawMoney(ticketBooth.WaterBottlePrice * 2); } decimal waterPayment = this.wallet.RemoveMoney(ticketBooth.WaterBottlePrice); WaterBottle bottle = ticketBooth.SellWaterBottle(waterPayment); return(result); }