コード例 #1
0
        private void InitMachine()
        {
            var machine = new VendingMachine();

            machine.InitMachine();
            MachineMemoryManager.InsertMachine(machine);
        }
コード例 #2
0
        public override void ProcessRequest(HttpContext context)
        {
            var machine = MachineMemoryManager.Instance();
            var userBug = UserBugMemoryManager.Instance();

            machine.PayOut(userBug);
            MachineMemoryManager.InsertMachine(machine);
            UserBugMemoryManager.InsertBug(userBug);
            WriteResult(context.Response, new
            {
                Result  = true,
                UserBug = userBug
            });
        }
コード例 #3
0
        public override void ProcessRequest(HttpContext context)
        {
            var  coin    = JsonConvert.DeserializeObject <CoinModel>(context.Request.QueryString["coin"]);
            var  machine = MachineMemoryManager.Instance();
            var  userBug = UserBugMemoryManager.Instance();
            bool result  = userBug.InsertCoinToMachine(machine, coin);

            MachineMemoryManager.InsertMachine(machine);
            UserBugMemoryManager.InsertBug(userBug);
            WriteResult(context.Response, new
            {
                Result     = result,
                UserSumRur = machine.UserSumRur
            });
        }
コード例 #4
0
        public override void ProcessRequest(HttpContext context)
        {
            var productType = (ProductTypeEnum)Convert.ToInt32(context.Request.QueryString["productType"]);
            var machine     = MachineMemoryManager.Instance();
            var result      = machine.BuyProduct(productType);

            MachineMemoryManager.InsertMachine(machine);
            var port = machine.GetPortForProduct(productType);

            WriteResult(context.Response, new
            {
                Result       = result.Result,
                Message      = result.Message,
                UserSumRur   = machine.UserSumRur,
                ProductCount = port.ProductCount
            });
        }