Example #1
0
        private bool IsCTriFull(Ctri ct)
        {
            Stack <Papier>    pilePapier    = ct.getPilePapier;
            Stack <Verre>     pileVerre     = ct.getPileVerre;
            Stack <Plastique> pilePlastique = ct.getPilePlastique;
            Stack <Feraille>  pileFerraille = ct.getPileFerraile;
            Stack <Terre>     pileTerre     = ct.getPileTerre;


            if (pilePapier.Count() == ct.getTabMax[0])
            {
                return(false);
            }
            else
            {
                if (pileVerre.Count() == ct.getTabMax[1])
                {
                    return(false);
                }
                else
                {
                    if (pilePlastique.Count() == ct.getTabMax[2])
                    {
                        return(false);
                    }
                    else
                    {
                        if (pileFerraille.Count() == ct.getTabMax[3])
                        {
                            return(false);
                        }
                        else
                        {
                            if (pileTerre.Count() == ct.getTabMax[4])
                            {
                                return(false);
                            }
                            else
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void Cree_Centre_trie(int choix)
        {
            Ctri centreTri;

            tabCentreTri = new Ctri[choix * 10];
            for (int i = 1; i <= (choix * 10); i++)
            {
                if (IsEven(i))
                {
                    centreTri = new Ctri(true);
                }
                else
                {
                    centreTri = new Ctri(false);
                }
                tabCentreTri[i - 1] = centreTri;
            }
        }
Example #3
0
        private void Vider_Vaisseau(Ship vaisseau, Ctri centreTri)
        {
            Stack <Papier>    pilePapier;
            Stack <Verre>     pileVerre;
            Stack <Plastique> pilePlastique;
            Stack <Feraille>  pileFerraille;
            Stack <Terre>     pileTerre;
            Papier            papier    = new Papier(0);
            Verre             verre     = new Verre(0);
            Plastique         plastique = new Plastique(0);
            Feraille          feraille  = new Feraille(0);
            Terre             terre     = new Terre(0);

            //Papier
            for (int i = 1; i <= vaisseau.getPapier; i++)
            {
                pilePapier = centreTri.getPilePapier;
                if (IsCTriFull(centreTri))
                {
                    pilePapier.Push(papier);
                    centreTri.setPilePapier = pilePapier;
                }
                else
                {
                    do
                    {
                    } while (pilePapier.Count == 0);
                }
            }
            //Verre
            for (int i = 1; i <= vaisseau.getVerre; i++)
            {
                pileVerre = centreTri.getPileVerre;
                if (IsCTriFull(centreTri))
                {
                    pileVerre.Push(verre);
                    centreTri.setPileVerre = pileVerre;
                }
                else
                {
                    do
                    {
                    } while (pileVerre.Count == 0);
                }
            }
            //Plastique
            for (int i = 1; i <= vaisseau.getPlastique; i++)
            {
                pilePlastique = centreTri.getPilePlastique;
                if (IsCTriFull(centreTri))
                {
                    pilePlastique.Push(plastique);
                    centreTri.setPilePlastique = pilePlastique;
                }
                else
                {
                    do
                    {
                    } while (pilePlastique.Count == 0);
                }
            }
            //Feraille
            for (int i = 1; i <= vaisseau.getFerraille; i++)
            {
                pileFerraille = centreTri.getPileFerraile;
                if (IsCTriFull(centreTri))
                {
                    pileFerraille.Push(feraille);
                    centreTri.setPileFerraille = pileFerraille;
                }
                else
                {
                    do
                    {
                    } while (pileFerraille.Count == 0);
                }
            }
            //Terre Contaminé
            for (int i = 1; i <= vaisseau.getTerreConta; i++)
            {
                pileTerre = centreTri.getPileTerre;
                if (IsCTriFull(centreTri))
                {
                    pileTerre.Push(terre);
                    centreTri.setPileTerre = pileTerre;
                }
                else
                {
                    do
                    {
                    } while (pileTerre.Count == 0);
                }
            }
        }