Example #1
0
 private void startSmoking(Cigar cigar)
 {
     isSmoking = true;
     View.message(" has been started to smoke.");
     while (cigar.isBurning())
     {
         Thread.Sleep(800);
         cigar.use();
     }
     isSmoking = false;
     View.message(" has been finished the smoking.");
 }
Example #2
0
 private void smokerThreadRoutine()
 {
     while (true)
     {
         Thread.Sleep(100);
         if (!isSmoking && hasRequiredIngridientsToMakeACigar())
         {
             View.message(" is ready to make a cigar");
             table.pullResources(); //TODO: use retrieved resources to build new cigar
             Cigar cigar = new Cigar();
             startSmoking(cigar);
         }
     }
 }
Example #3
0
        private bool hasRequiredIngridientsToMakeACigar()
        {
            List <Resource.TypeEnum> requiredIngridients = Cigar.getIngridientsList();
            List <Resource.TypeEnum> availableResources  = getAvailableResources();

            foreach (Resource.TypeEnum ingridient in availableResources)
            {
                if (requiredIngridients.Contains(ingridient))
                {
                    requiredIngridients.RemoveAll((Resource.TypeEnum elem) => (elem == ingridient));
                }

                if (requiredIngridients.Count == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
 private void startSmoking(Cigar cigar)
 {
     isSmoking = true;
     View.message(" has been started to smoke.");
     while (cigar.isBurning())
     {
         Thread.Sleep(800);
         cigar.use();
     }
     isSmoking = false;
     View.message(" has been finished the smoking.");
 }
 private void smokerThreadRoutine()
 {
     while (true)
     {
         Thread.Sleep(100);
         if (!isSmoking && hasRequiredIngridientsToMakeACigar())
         {
             View.message(" is ready to make a cigar");
             table.pullResources(); //TODO: use retrieved resources to build new cigar
             Cigar cigar = new Cigar();
             startSmoking(cigar);
         }
     }
 }