Exemplo n.º 1
0
 public Dustbin(string name)
 {
     color             = DustbinColor();
     this.name         = name;
     PaperContent      = new PaperGarbage[0];
     PlasticContent    = new PlasticGarbage[0];
     HouseWasteContent = new Garbage[0];
 }
Exemplo n.º 2
0
 public void EmptyContents()
 {
     PaperGarbage[]   tmpPap = new PaperGarbage[0];
     PlasticGarbage[] tmpPla = new PlasticGarbage[0];
     Garbage[]        tmpGar = new Garbage[0];
     PaperContent      = tmpPap;
     PlasticContent    = tmpPla;
     HouseWasteContent = tmpGar;
 }
Exemplo n.º 3
0
        public void ThrowOutGarbage(Garbage garbage)
        {
            if (garbage is PlasticGarbage)
            {
                PlasticGarbage garbage1 = (PlasticGarbage)garbage;
                if (!garbage1.IsCleaned)
                {
                    garbage1.Clean();
                    Console.WriteLine("This garbage had to be cleaned");
                }
                Garbage[] tmp = new Garbage[HouseWasteContent.Length + 1];
                tmp[HouseWasteContent.Length] = garbage1;
                HouseWasteContent             = tmp;

                PlasticGarbage[] plaTmp = new PlasticGarbage[PlasticContent.Length - 1];
                PlasticContent = plaTmp;
            }
            else if (garbage is PaperGarbage)
            {
                PaperGarbage garbage1 = (PaperGarbage)garbage;
                if (!garbage1.IsSqueezed)
                {
                    garbage1.Squeeze();
                    Console.WriteLine("This garbage had to be squeezed");
                }
                Garbage[] tmp = new Garbage[HouseWasteContent.Length + 1];
                tmp[HouseWasteContent.Length] = garbage1;
                HouseWasteContent             = tmp;

                PaperGarbage[] papTmp = new PaperGarbage[PaperContent.Length - 1];
                PaperContent = papTmp;
            }
            else
            {
                Garbage[] tmp = new Garbage[HouseWasteContent.Length + 1];
                tmp[HouseWasteContent.Length] = garbage;
                HouseWasteContent             = tmp;

                Garbage[] garTmp = new Garbage[HouseWasteContent.Length - 1];
                HouseWasteContent = garTmp;
            }
        }