Пример #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("The workers coming out,and sit on the branch");
            Console.WriteLine("They are eating their lunch:tomatoes,joghurt bread,and some sausages.");
            Console.WriteLine("Oh wait one of the tomatoes is rotten,the worker spot a dustbin and said this:'look at this guys a 360 noscope'");
            Dustbin Dustbin = new Dustbin("red");

            Console.WriteLine(",but he failed the throw so the rotten tomato fall beside the dustbin.");
            Garbage rottenTomatoe = new Garbage("rottentomato");

            Console.WriteLine("After then the workers finished their lunch,but because they are uncultured swines");
            Console.WriteLine("They throw the trash onto the ground.");
            PlasticGarbage joghurt     = new PlasticGarbage("joghurt", false);
            PlasticGarbage sausageWrap = new PlasticGarbage("sausagewrap", true);

            Console.WriteLine("One of the workers lit a cigar,and as this was the last cigar in the box,he threw also the cigar box onto the ground");
            PaperGarbage cigarBox = new PaperGarbage("cigarbox", false);

            Console.WriteLine("After this they go back to work,and the cleaning ladies are coming");
            Console.WriteLine("As soon as they see the mess,they say a loud f**k!");
            Console.WriteLine("One of the ladies pick up the rotten tomatoes and throw in the Dustbin");
            Dustbin.ThrowOutGarbage(rottenTomatoe);
            Console.WriteLine("They pick up the joghurt and clean it");
            joghurt.Clean();
            Console.WriteLine("After then they throw into the dustbin and also the sausages wrap");
            Dustbin.ThrowOutGarbage(joghurt);
            Dustbin.ThrowOutGarbage(sausageWrap);
            Console.WriteLine("They spot the cigarbox also,so they squeezed it and throw out");
            cigarBox.Squeeze();
            Dustbin.ThrowOutGarbage(cigarBox);
            Console.WriteLine("Now the Dustbin's content are: ");
            Dustbin.DisplayContents();
        }
Пример #2
0
        public static void Main(string[] args)
        {
            Garbage[] rottenTomatoes = new Garbage[3];
            for (int i = 0; i < rottenTomatoes.Length; i++)
            {
                rottenTomatoes[i] = new Garbage("rotten tomato nr." + (i + 1));
            }

            PlasticGarbage milkJug = new PlasticGarbage("plastic milk jug", true);

            PaperGarbage nemzetiSport = new PaperGarbage("Nemzeti Sport", true);

            Dustbin dustbin = new Dustbin("Jenny's handsome");


            Console.WriteLine("1. ROUND:");
            dustbin.DisplayContents();
            dustbin.ThrowOutGarbage(milkJug);
            dustbin.ThrowOutGarbage(nemzetiSport);
            for (int i = 0; i < rottenTomatoes.Length; i++)
            {
                dustbin.ThrowOutGarbage(rottenTomatoes[i]);
            }
            Console.WriteLine("---------------------------");
            Console.WriteLine("2. ROUND:");
            dustbin.DisplayContents();
            dustbin.EmptyContents();
            Console.WriteLine("---------------------------");
            Console.WriteLine("3. ROUND:");
            dustbin.DisplayContents();
        }
Пример #3
0
 public Dustbin(string color)
 {
     this.Color        = color;
     PaperContent      = new PaperGarbage[0];
     PlasticContent    = new PlasticGarbage[0];
     HouseWasteContent = new Garbage[0];
 }
Пример #4
0
        public void ThrowOutGarbage(Garbage garbage)
        {
            // Plastic Garbage
            if (garbage is PlasticGarbage)
            {
                PlasticGarbage newgarbage1 = (PlasticGarbage)garbage;
                if (!(newgarbage1.isCleaned()))
                {
                    throw new DustbinContentException("exception!");
                }
                else
                {
                    PlasticGarbage[] Temp = new PlasticGarbage[PlasticContent.Length + 1];
                    for (int i = 0; i < PlasticContent.Length; i++)
                    {
                        Temp[i] = newgarbage1;
                    }
                    Temp[Temp.Length - 1] = newgarbage1;
                    PlasticContent        = Temp;
                }
            }

            //Paper Garbage
            else if (garbage is PaperGarbage)
            {
                PaperGarbage newgarbage2 = (PaperGarbage)garbage;
                if (!(newgarbage2.isSqueezed()))
                {
                    throw new DustbinContentException("exception!");
                }
                else
                {
                    PaperGarbage[] Temp = new PaperGarbage[PaperContent.Length + 1];
                    for (int i = 0; i < PaperContent.Length; i++)
                    {
                        Temp[i] = newgarbage2;
                    }
                    Temp[Temp.Length - 1] = newgarbage2;
                    PaperContent          = Temp;
                }
            }

            else if (garbage is Garbage)
            {
                Garbage   newgarbage3 = (Garbage)garbage;
                Garbage[] Temp        = new Garbage[HouseWasteContent.Length + 1];
                for (int i = 0; i < HouseWasteContent.Length; i++)
                {
                    Temp[i] = HouseWasteContent[i];
                }
                Temp[Temp.Length - 1] = newgarbage3;
                HouseWasteContent     = Temp;
            }

            else if (!(garbage is Garbage) && !(garbage is PaperGarbage) && !(garbage is Garbage))
            {
                throw new DustbinContentException("exception!");
            }
        }
Пример #5
0
        public static void Main(string[] args)
        {
            PaperGarbage paperbox   = new PaperGarbage("paperbox", false);
            Dustbin      redDustBin = new Dustbin("Red");

            Console.WriteLine(redDustBin.Color);
            Console.ReadLine();
        }
Пример #6
0
 public void ThrowOutGarbage(Garbage garbage)
 {
     if (garbage is PlasticGarbage)
     {
         PlasticGarbage plasticGarbage = (PlasticGarbage)garbage;
         if (plasticGarbage.Cleaned)
         {
             int newLength = PlasticContent.Length + 1;
             PlasticContent = new PlasticGarbage[newLength];
             PlasticContent[newLength - 1] = plasticGarbage;
             Console.WriteLine("plastic +1!");
         }
         else
         {
             throw new DustbinContentException();
         }
     }
     else
     {
         if (garbage is PaperGarbage)
         {
             PaperGarbage paperGarbage = (PaperGarbage)garbage;
             if (paperGarbage.Squeezed)
             {
                 int newLength = PaperContent.Length + 1;
                 PaperContent = new PaperGarbage[newLength];
                 PaperContent[newLength - 1] = paperGarbage;
                 Console.WriteLine("paper +1!");
             }
             else
             {
                 throw new DustbinContentException();
             }
         }
         else
         {
             if (garbage is Garbage)
             {
                 int newLength = HouseWasteContent.Length + 1;
                 HouseWasteContent = new Garbage[newLength];
                 HouseWasteContent[newLength - 1] = garbage;
                 Console.WriteLine("house +1!");
             }
             else
             {
                 throw new DustbinContentException();
             }
         }
     }
 }
Пример #7
0
        public void ThrowOutGarbage(Garbage garbage)
        {
            // Throw Out Plastic Garbage
            if (garbage is PlasticGarbage)
            {
                PlasticGarbage plasticGarbage = (PlasticGarbage)garbage;
                if (plasticGarbage.Cleaned)
                {
                    int temp = PlasticContent.Length + 1;
                    PlasticContent           = new PlasticGarbage[temp];
                    PlasticContent[temp - 1] = plasticGarbage;
                }
                else
                {
                    throw new DustbinContentException();
                }
            }

            // Throw Out Paper Garbage
            else if (garbage is PaperGarbage)
            {
                PaperGarbage paperGarbage = (PaperGarbage)garbage;
                if (paperGarbage.Squeezed)
                {
                    int temp = PaperContent.Length + 1;
                    PaperContent           = new PaperGarbage[temp];
                    PaperContent[temp - 1] = paperGarbage;
                }
                else
                {
                    throw new DustbinContentException();
                }
            }

            // Throw Out Garbage
            else if (garbage is Garbage)
            {
                int temp = HouseWasteContent.Length + 1;
                HouseWasteContent           = new Garbage[temp];
                HouseWasteContent[temp - 1] = garbage;
            }
        }
Пример #8
0
 public void EmptyContents()
 {
     PaperContent      = new PaperGarbage[0];
     PlasticContent    = new PlasticGarbage[0];
     HouseWasteContent = new Garbage[0];
 }