Exemple #1
0
        private static void fillTheGlases(int r, int g)
        {
            Glas   theGlas = TopGlas;
            double MillSec = 0;

            while (theGlas.BelowRight != null)
            {
                if (theGlas.r == r)
                {
                    break;
                }
                else
                {
                    //Console.WriteLine(theGlas.r);
                    theGlas = theGlas.BelowRight;
                }
            }
            while (theGlas.GlasToLeft != null)
            {
                if (theGlas.g == g)
                {
                    break;
                }
                else
                {
                    //Console.WriteLine(theGlas.g);
                    theGlas = theGlas.GlasToLeft;
                }
            }
            Console.WriteLine("Glaset på den " + theGlas.r + " raden, " + theGlas.g + " från vänster");
            //10.000 millisekunder
            while (theGlas.isNotFull)
            {
                TopGlas.addLiquid(1);
                MillSec = MillSec + 100;
            }



            Console.WriteLine("Det tar " + MillSec / 100000 + " sekunder tills den är fyld");
        }
Exemple #2
0
        internal void addLiquid(double l)
        {
            ContainWatter = ContainWatter + l;

            if (ContainWatter > Overflowlimit)
            {
                isNotFull = false;
                double thespill = ContainWatter - Overflowlimit;
                //Console.WriteLine("Spill:  " +thespill + " half of it: " + thespill/2);

                if (BelowLeft != null)
                {
                    BelowLeft.addLiquid(thespill / 2);
                }
                if (BelowRight != null)
                {
                    BelowRight.addLiquid(thespill / 2);
                }
                ContainWatter = Overflowlimit;
            }



            //if (ContainWatter> Overflow)
            //{
            //    isNotFull = false;
            //    double Theoverflow = (Overflow - ContainWatter) / 2;
            //    Console.WriteLine(Theoverflow);
            //    ContainWatter = ContainWatter - Theoverflow;

            //    if (BelowLeft != null)
            //    {
            //        BelowLeft.addLiquid(Theoverflow);
            //    }
            //    if(BelowRight != null)
            //    {
            //        BelowRight.addLiquid(Theoverflow);
            //    }

            //}
        }