Exemple #1
0
    static void Main(string[] args)
    {
        // Initialize the trash cans and the trash master:
        Console.WriteLine("Hello Garbage!");

        var trashCans = new TrashCan[]
        {
            new TrashCan(0, 1000),
            new TrashCan(1, 800),
            new TrashCan(2, 1200),
            new TrashCan(3, 1500)
        };

        var trashMaster = new GarbageTruck();
        var rand        = new Random();

        // Link the garbage truck to the cans:
        foreach (var trashCan in trashCans)
        {
            trashCan.OnTrashCanOverflow += trashMaster.HandleTrashCanOverflow;
        }

        // Generate random amounts of garbage:
        while (true)
        {
            var newGarbageVolume = 100 * rand.NextDouble();
            Console.WriteLine("Adding {0:F2}l ...", newGarbageVolume);
            trashCans[rand.Next(trashCans.Length)].UsedVolume += newGarbageVolume;

            Thread.Sleep(500);
        }
    }
        public async Task <IActionResult> Edit(int id, [Bind("Id,NumberPlate,Model,Volume,MaintananceCostFactor")] GarbageTruck garbageTruck)
        {
            if (id != garbageTruck.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(garbageTruck);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GarbageTruckExists(garbageTruck.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(garbageTruck));
        }
Exemple #3
0
 void Start()
 {
     Cursor.lockState    = CursorLockMode.Locked;
     Cursor.visible      = false;
     Time.timeScale      = 0;
     timer               = GetComponent <Timer>();
     timer.timeRemaining = timerLength;
     StartCoroutine(StartTimer());
     scoreKeeper = GameObject.FindGameObjectWithTag("Garbage Truck").GetComponent <GarbageTruck>();
 }
Exemple #4
0
    public void DisplayConentOfGarbageTruck(GarbageTruck garbageTruck)
    {
        _currentAmountOfAluminium = _currentAmountOfAluminium + garbageTruck.CurrentStateStorageForAluminium();
        _currentAmountOfGlass     = _currentAmountOfGlass + garbageTruck.CurrentStateStorageForGlass();
        _currentAmountOfPaper     = _currentAmountOfPaper + garbageTruck.CurrentStateStorageForPaper();

        _contentOfGarbageTruck.text = ("Zawartość śmieciarki: " + "\n" +
                                       "Aluminium: " + _currentAmountOfAluminium + "\n" +
                                       "Szklo: " + _currentAmountOfGlass + "\n" +
                                       "Papier: " + _currentAmountOfPaper);
    }
        public async Task <IActionResult> Create([Bind("Id,NumberPlate,Model,Volume,MaintananceCostFactor")] GarbageTruck garbageTruck)
        {
            if (ModelState.IsValid)
            {
                _context.Add(garbageTruck);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(garbageTruck));
        }
Exemple #6
0
    //Event which react on colision between specific bin and garbage truck.
    void OnTriggerEnter2D(Collider2D coll)
    {
        _trashGenerator = new TrashGenerator();
        _garbageTruck   = new GarbageTruck();
        _decisionTree   = new DecisionTree();

        if (coll.name.StartsWith("SmietnikAluminium"))
        {
            _binOfAluminium = new BinOfAluminium();

            while (_binOfAluminium.AmountOfEmptySpaceOfBin())
            {
                _binOfAluminium.AddTrashToBin(_trashGenerator.GetResult());
            }

            for (int index = 0; index < _binOfAluminium.ContentOfBin.Length; index++)
            {
                if (_decisionTree.CheckWeight(_binOfAluminium.ContentOfBin[index]) == "NextTest")
                {
                    if (_decisionTree.CheckAbilityOfCrushing(_binOfAluminium.ContentOfBin[index]) == "NextTest")
                    {
                        if (_decisionTree.CheckAbsorptionOfHeat(_binOfAluminium.ContentOfBin[index]) == "Paper")
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfAluminium.ContentOfBin[index]);
                        }
                        else if (_decisionTree.CheckAbsorptionOfHeat(_binOfAluminium.ContentOfBin[index]) == "Glass")
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Glass", _binOfAluminium.ContentOfBin[index]);
                        }
                        else
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfAluminium.ContentOfBin[index]);
                        }
                    }
                    else if (_decisionTree.CheckAbilityOfCrushing(_binOfAluminium.ContentOfBin[index]) == "Paper")
                    {
                        _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfAluminium.ContentOfBin[index]);
                    }
                    else
                    {
                        _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfAluminium.ContentOfBin[index]);
                    }
                }
                else if (_decisionTree.CheckWeight(_binOfAluminium.ContentOfBin[index]) == "Paper")
                {
                    _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfAluminium.ContentOfBin[index]);
                }
                else
                {
                    _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfAluminium.ContentOfBin[index]);
                }
            }

            DisplayConentOfGarbageTruck(_garbageTruck);
            DisplayContentBin(_binOfAluminium);
            Destroy(coll.gameObject);
        }

        if (coll.name.StartsWith("SmietnikPapier"))
        {
            _binOfPaper = new BinOfPaper();

            while (_binOfPaper.AmountOfEmptySpaceOfBin())
            {
                _binOfPaper.AddTrashToBin(_trashGenerator.GetResult());
            }
            for (int index = 0; index < _binOfPaper.ContentOfBin.Length; index++)
            {
                if (_decisionTree.CheckWeight(_binOfPaper.ContentOfBin[index]) == "NextTest")
                {
                    if (_decisionTree.CheckAbilityOfCrushing(_binOfPaper.ContentOfBin[index]) == "NextTest")
                    {
                        if (_decisionTree.CheckAbsorptionOfHeat(_binOfPaper.ContentOfBin[index]) == "Paper")
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfPaper.ContentOfBin[index]);
                        }
                        else if (_decisionTree.CheckAbsorptionOfHeat(_binOfPaper.ContentOfBin[index]) == "Glass")
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Glass", _binOfPaper.ContentOfBin[index]);
                        }
                        else
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfPaper.ContentOfBin[index]);
                        }
                    }
                    else if (_decisionTree.CheckAbilityOfCrushing(_binOfPaper.ContentOfBin[index]) == "Paper")
                    {
                        _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfPaper.ContentOfBin[index]);
                    }
                    else
                    {
                        _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfPaper.ContentOfBin[index]);
                    }
                }
                else if (_decisionTree.CheckWeight(_binOfPaper.ContentOfBin[index]) == "Paper")
                {
                    _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfPaper.ContentOfBin[index]);
                }
                else
                {
                    _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfPaper.ContentOfBin[index]);
                }
            }

            DisplayConentOfGarbageTruck(_garbageTruck);
            DisplayContentBin(_binOfPaper);
            Destroy(coll.gameObject);
        }

        if (coll.name.StartsWith("SmietnikPlastik"))
        {
            _binOfGlass = new BinOfGlass();

            while (_binOfGlass.AmountOfEmptySpaceOfBin())
            {
                _binOfGlass.AddTrashToBin(_trashGenerator.GetResult());
            }

            for (int index = 0; index < _binOfGlass.ContentOfBin.Length; index++)
            {
                if (_decisionTree.CheckWeight(_binOfGlass.ContentOfBin[index]) == "NextTest")
                {
                    if (_decisionTree.CheckAbilityOfCrushing(_binOfGlass.ContentOfBin[index]) == "NextTest")
                    {
                        if (_decisionTree.CheckAbsorptionOfHeat(_binOfGlass.ContentOfBin[index]) == "Paper")
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfGlass.ContentOfBin[index]);
                        }
                        else if (_decisionTree.CheckAbsorptionOfHeat(_binOfGlass.ContentOfBin[index]) == "Glass")
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Glass", _binOfGlass.ContentOfBin[index]);
                        }
                        else
                        {
                            _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfGlass.ContentOfBin[index]);
                        }
                    }
                    else if (_decisionTree.CheckAbilityOfCrushing(_binOfGlass.ContentOfBin[index]) == "Paper")
                    {
                        _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfGlass.ContentOfBin[index]);
                    }
                    else
                    {
                        _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfGlass.ContentOfBin[index]);
                    }
                }
                else if (_decisionTree.CheckWeight(_binOfGlass.ContentOfBin[index]) == "Paper")
                {
                    _garbageTruck.AddTrashToGarbageTruck("Paper", _binOfGlass.ContentOfBin[index]);
                }
                else
                {
                    _garbageTruck.AddTrashToGarbageTruck("Aluminium", _binOfGlass.ContentOfBin[index]);
                }
            }

            DisplayConentOfGarbageTruck(_garbageTruck);
            DisplayContentBin(_binOfGlass);
            Destroy(coll.gameObject);
        }
    }