Example #1
0
        private static void BuyWater()
        {
            if (_amount % 100 != 0)
            {
                Supplies.IsError = true;
                Supplies.Message = "[error]: Your quantity must be a multiple of 100!";
                return;
            }

            var cost = _amount / 100;    //100ml for 1 money


            if (cost > Supplies.Money)
            {
                Supplies.IsError = true;
                Supplies.Message = $"[error]: You do not have enough money! Required : {cost}";
                return;
            }


            var message = $"{_amount}ml of water was bought for {cost} money! (1 money for every 100ml of water)";

            Supplies.Water  += _amount;
            Supplies.Money  -= cost;
            Supplies.Message = message;
            Supplies.AddTransaction(cost, "Water", _amount);
        }
Example #2
0
        private static void BuyChocolate()
        {
            if (_amount % 2 != 0)
            {
                Supplies.IsError = true;
                Supplies.Message = "[error]: Your quantity must be a multiple of 2!";
                return;
            }

            var cost = _amount / 2; //2g for 1 money


            if (cost > Supplies.Money)
            {
                Supplies.IsError = true;
                Supplies.Message = $"[error]: You do not have enough money! Required : {cost}";
                return;
            }


            var message = $"{_amount}g of chocolate was bought for {cost} money! (1 money for every 2g of chocolate)";

            Supplies.Chocolate += _amount;
            Supplies.Money     -= cost;
            Supplies.Message    = message;
            Supplies.AddTransaction(cost, "Chocolate", _amount);
        }
Example #3
0
        private static void BuyFlour()
        {
            if (_amount % 50 != 0)
            {
                Supplies.IsError = true;
                Supplies.Message = "[error]: Your quantity must be a multiple of 50!";
                return;
            }

            var cost = _amount / 50; //50g for 1 money


            if (cost > Supplies.Money)
            {
                Supplies.IsError = true;
                Supplies.Message = $"[error]: You do not have enough money! Required : {cost}";
                return;
            }


            var message = $"{_amount}g of flour was bought for {cost} money! (1 money for every 50g of flour)";

            Supplies.Flour  += _amount;
            Supplies.Money  -= cost;
            Supplies.Message = message;
            Supplies.AddTransaction(cost, "Flour", _amount);
        }
Example #4
0
        private static void BuyCoffeeBeans()
        {
            if (_amount % 10 != 0)
            {
                Supplies.IsError = true;
                Supplies.Message = "[error]: Your quantity must be a multiple of 10!";
                return;
            }

            var cost = _amount / 10;    //10g for 1 money


            if (cost > Supplies.Money)
            {
                Supplies.IsError = true;
                Supplies.Message = $"[error]: You do not have enough money! Required : {cost}";
                return;
            }


            var message = $"{_amount}g of Coffee Beans was bought for {cost} money! (1 money for every 10g of coffee beans)";

            Supplies.CoffeeBeans += _amount;
            Supplies.Money       -= cost;
            Supplies.Message      = message;
            Supplies.AddTransaction(cost, "Coffee Beans", _amount);
        }
Example #5
0
        private static void BuyEggs()
        {
            var cost = _amount * 5; //1 egg for 5 money


            if (cost > Supplies.Money)
            {
                Supplies.IsError = true;
                Supplies.Message = $"[error]: You do not have enough money! Required : {cost}";
                return;
            }


            var message = $"{_amount} eggs was bought for {cost} money! (5 money for every egg)";

            Supplies.Egg    += _amount;
            Supplies.Money  -= cost;
            Supplies.Message = message;
            Supplies.AddTransaction(cost, "Egg(s)", _amount);
        }