/// <summary>
        /// Initializes a new instance of the MoneyCollectingBooth class.
        /// </summary>
        /// <param name="attendent"> The attendant for the booth.</param>
        /// <param name="ticketPrice"> The price of the tickets.</param>
        /// <param name="waterBottlePrice"> The price of the water bottles.</param>
        public MoneyCollectingBooth(Employee attendant, decimal ticketPrice, decimal waterBottlePrice, IMoneyCollector moneyBox)
            : base(attendant)
        {
            this.moneyBox = moneyBox;


            this.ticketPrice      = ticketPrice;
            this.waterBottlePrice = waterBottlePrice;


            // Creates 5 tickets.
            for (int t = 0; t < 5; t++)
            {
                // Create a variable of type ticket and pass in the correct parameters.
                Ticket ticket = new Ticket(15, t + 1, .01);

                Items.Add(ticket);
            }

            // Creates 5 water bottles.
            for (int w = 0; w < 5; w++)
            {
                // Creates a new water bottle and pass in the correct parameters.
                WaterBottle waterBottle = new WaterBottle(3, w + 1, 1);

                Items.Add(waterBottle);

                this.waterBottlePrice = waterBottle.Price;
            }
        }
Exemple #2
0
        /// <summary>
        /// Sells a water bottle.
        /// </summary>
        /// <param name="payment">The payment for the water bottle.</param>
        /// <returns>The sold water bottle.</returns>
        public WaterBottle SellWaterBottle(decimal payment)
        {
            WaterBottle waterBottle = null;

            try
            {
                // If a sufficient payment was received...
                if (payment >= this.WaterBottlePrice)
                {
                    // Find the first water bottle.
                    waterBottle = this.Attendant.FindItem(this.Items, typeof(WaterBottle)) as WaterBottle;
                }

                // If a water bottle was found...
                if (waterBottle != null)
                {
                    // Add payment to money box.
                    this.AddMoney(payment);
                }
            }
            catch (MissingItemException ex)
            {
                throw new NullReferenceException("Water bottle not found.", ex);
            }


            return(waterBottle);
        }
Exemple #3
0
        /// <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(Booth 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);

            // Gets the map.
            Map map = ticketBooth.GiveFreeMap();

            // Gets  the coupon book.
            CouponBook couponBook = ticketBooth.GiveFreeCouponBook();

            return(ticket);
        }
Exemple #4
0
        /// <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);
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the MoneyCollectingBooth class.
        /// </summary>
        /// <param name="attendant">The booth's attendant.</param>
        /// <param name="ticketPrice">The price of the ticket.</param>
        /// <param name="waterBottlePrice">The price of the water bottle.</param>
        /// <param name="moneyBox">The money box used to house money.</param>
        public MoneyCollectingBooth(Employee attendant, decimal ticketPrice, decimal waterBottlePrice, IMoneyCollector moneyBox)
            : base(attendant)
        {
            this.ticketPrice      = ticketPrice;
            this.waterBottlePrice = waterBottlePrice;
            this.moneyBox         = moneyBox;
            //// this.moneyBox.AddMoney(42.75m);

            // Instantiates a new ticket stack.
            this.ticketStack = new Stack <Ticket>();

            // Create tickets with unique serial numbers and add them to the list.
            for (int i = 0; i < 5; i++)
            {
                Ticket ticket = new Ticket(15.00m, i, .01);
                i = ticket.SerialNumber;
                ////this.Items.Add(ticket);
                this.ticketStack.Push(ticket);
            }

            // Create water bottles with unique serial numbers and add them to the list.
            for (int i = 0; i < 5; i++)
            {
                WaterBottle waterBottle = new WaterBottle(this.WaterBottlePrice, i, 1);
                i = waterBottle.SerialNumber;
                this.Items.Add(waterBottle);
            }
        }
Exemple #6
0
        /// <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>
        /// Sells the water bottle.
        /// </summary>
        /// <param name="payment"> The payment for the water bottle.</param>
        /// <returns> The water bottle that was sold.</returns>
        public WaterBottle SellWaterBottle(decimal payment)
        {
            // Try selilng the water bottle.
            try
            {
                WaterBottle waterBottle = null;

                // If the payment is equal to the price of the water bottle.
                if (payment == this.waterBottlePrice)
                {
                    waterBottle = this.Attendant.FindItem(this.Items, typeof(WaterBottle)) as WaterBottle;

                    // If the bottle was bought then add the money to the booths money balance.
                    if (waterBottle != null)
                    {
                        // Add the payment to the money balance.
                        this.AddMoney(payment);
                    }
                }

                return(waterBottle);
            }
            // If the water bottle cannot be found throw a new expection.
            catch (MissingItemException)
            {
                throw new MissingItemException("Cannot find water bottle.");
            }
        }
Exemple #8
0
        public async Task TestPutInputWithDifferentOutput()
        {
            var client   = new WebApiClient(TestClient);
            var url      = "/api/webapiclienttest/TestPutInputWithDifferentOutput";
            var response = await client.PutAsync <Speaker, WaterBottle>(url, WaterBottle.CreateInstance());

            Assert.AreEqual("JBL", response.ResponseValue.Brand);
            TestHttpResults(response);
        }
Exemple #9
0
        public async Task TestPostInputWithOutput()
        {
            var client   = new WebApiClient(TestClient);
            var url      = "/api/webapiclienttest/TestPostInputWithOutput";
            var response = await client.PostAsync(url, WaterBottle.CreateInstance());

            Assert.AreEqual("Ozarka", response.ResponseValue.Brand);
            TestHttpResults(response);
        }
Exemple #10
0
        public async Task TestPostInputNoOutput()
        {
            var client   = new WebApiClient(TestClient);
            var url      = "/api/webapiclienttest/TestPostInputNoOutput";
            var response = await client.PostAsync(url, WaterBottle.CreateInstance());

            Assert.IsNull(response.ResponseValue);
            TestHttpResults(response);
        }
Exemple #11
0
        /// <summary>
        /// Initializes a new instance of the Booth class.
        /// </summary>
        /// <param name="attendant">The employee to be the booth's attendant.</param>
        /// <param name="ticketPrice">The price of a ticket.</param>
        /// <param name="waterBottlePrice"> The price of the water bottle.</param>
        public Booth(Employee attendant, decimal ticketPrice, decimal waterBottlePrice)
        {
            this.attendant   = attendant;
            this.ticketPrice = ticketPrice;
            //// DateTime today = new DateTime(2018, 6, 9);

            // Creates a list of coupon books.
            this.couponBooks = new List <CouponBook>();

            // Make 5 coupon books and stop at 5.
            for (int c = 0; c < 5; c++)
            {
                // Create a variable of type coupon book and pass in the correct parameters.
                CouponBook couponBook = new CouponBook(DateTime.Now, DateTime.Now.AddYears(1), 0.8);

                // Add the coupon book to the list of coupon books.
                this.couponBooks.Add(couponBook);
            }

            // Creates a new list of maps.
            this.maps = new List <Map>();

            // Make 10 maps.
            for (int m = 0; m < 10; m++)
            {
                // Create a variable of type map and pass in the correct parameters.
                Map map = new Map(.5, DateTime.Now);

                this.maps.Add(map);
            }

            // Creates a new list of tickets.
            this.tickets = new List <Ticket>();

            // Creates 5 tickets.
            for (int t = 0; t < 5; t++)
            {
                // Create a variable of type ticket and pass in the correct parameters.
                Ticket ticket = new Ticket(15, t + 1, .01);

                this.tickets.Add(ticket);
            }

            // Creates a list of water bottles.
            this.waterBottles = new List <WaterBottle>();

            // Creates 5 water bottles.
            for (int w = 0; w < 5; w++)
            {
                // Creates a new water bottle and pass in the correct parameters.
                WaterBottle waterBottle = new WaterBottle(3, w + 1, 1);

                this.waterBottles.Add(waterBottle);

                this.waterBottlePrice = waterBottle.Price;
            }
        }
Exemple #12
0
        public async Task <IActionResult> TestPutInputWithOutput([FromBody] WaterBottle waterBottle)
        {
            await Task.Delay(0);

            if (waterBottle != null && waterBottle.Brand == "Ozarka")
            {
                return(Ok(waterBottle));
            }
            else
            {
                throw new HttpException(HttpStatusCode.BadRequest, "Invalid Object");
            }
        }
Exemple #13
0
        /// <summary>
        /// Finds the water bottle.
        /// </summary>
        /// <param name="bottleBox"> The list of water bottles.</param>
        /// <returns> The water bottle that was found.</returns>
        public WaterBottle FindWaterBottler(List <WaterBottle> bottleBox)
        {
            WaterBottle waterBottle = null;

            // If there are still water bottles in stock then subtract one from the list.
            if (bottleBox.Count > 0)
            {
                // Take one water bottle.
                waterBottle = bottleBox[0];

                // Remove the water bottle from the list.
                bottleBox.Remove(waterBottle);
            }

            return(waterBottle);
        }
Exemple #14
0
        /// <summary>
        /// Sells the water bottle.
        /// </summary>
        /// <param name="payment"> The payment for the water bottle.</param>
        /// <returns> The water bottle that was sold.</returns>
        public WaterBottle SellWaterBottle(decimal payment)
        {
            WaterBottle waterBottle = null;

            // If the payment is equal to the price of the water bottle.
            if (payment == waterBottlePrice)
            {
                waterBottle = attendant.FindWaterBottler(waterBottles);

                // If the bottle was bought then add the money to the booths money balance.
                if (waterBottle != null)
                {
                    this.moneyBalance += payment;
                }
            }

            return(waterBottle);
        }
        /// <summary>
        /// Sells the water bottle.
        /// </summary>
        /// <param name="payment"> The payment for the water bottle.</param>
        /// <returns> The water bottle that was sold.</returns>
        public WaterBottle SellWaterBottle(decimal payment)
        {
            WaterBottle waterBottle = null;

            // If the payment is equal to the price of the water bottle.
            if (payment == this.waterBottlePrice)
            {
                waterBottle = this.Attendant.FindItem(this.Items, typeof(WaterBottle)) as WaterBottle;

                // If the bottle was bought then add the money to the booths money balance.
                if (waterBottle != null)
                {
                    // Add the payment to the money balance.
                    this.AddMoney(payment);
                }
            }

            return(waterBottle);
        }
Exemple #16
0
        /// <summary>
        /// Sells a water bottle.
        /// </summary>
        /// <param name="payment">The payment for the water bottle.</param>
        /// <returns>The sold water bottle.</returns>
        public WaterBottle SellWaterBottle(decimal payment)
        {
            WaterBottle result = null;

            try
            {
                if (payment >= this.WaterBottlePrice)
                {
                    result = this.Attendant.FindItem(this.Items, typeof(WaterBottle)) as WaterBottle;
                }

                if (result != null)
                {
                    this.AddMoney(payment);
                }
            }
            catch (MissingItemException ex)
            {
                throw new NullReferenceException("Water bottle not found.", ex);
            }

            return(result);
        }
Exemple #17
0
        /// <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);
        }
Exemple #19
0
 private void Awake()
 {
     instance = this;
 }
Exemple #20
0
        public async Task <IActionResult> TestGetObject()
        {
            var returnValue = await Task.FromResult(WaterBottle.CreateInstance());

            return(Ok(returnValue));
        }