Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("OMGHAI!");

            CompositeItem items = new CompositeItem();

            items.Add(EditableItem.Create(name: "+5 Dexterity Vest", sellIn: 10, quality: 20));
            items.Add(AgedBrie.Create(sellIn: 2, quality: 0));
            items.Add(EditableItem.Create(name: "Elixir of the Mongoose", sellIn: 5, quality: 7));
            items.Add(Sulfuras.Create(sellIn: 0, quality: 80));
            items.Add(Sulfuras.Create(sellIn: -1, quality: 80));
            items.Add(ConcertBackstagePass.Create(concertName: "TAFKAL80ETC", sellIn: 15, quality: 20));
            items.Add(ConcertBackstagePass.Create(concertName: "TAFKAL80ETC", sellIn: 10, quality: 49));
            items.Add(ConcertBackstagePass.Create(concertName: "TAFKAL80ETC", sellIn: 5, quality: 49));
            items.Add(Conjured.Create(name: "Conjured Mana Cake", sellIn: 3, quality: 6));

            GildedRose app = new GildedRose(items);


            for (var i = 0; i < 31; i++)
            {
                Console.WriteLine("-------- day " + i + " --------");
                Console.WriteLine("name, sellIn, quality");

                items.DisplayItems();

                app.UpdateItemsQualityAfterADay();
            }
        }
Ejemplo n.º 2
0
            public IGood BuildFor(Item item)
            {
                switch (item.Name)
                {
                case "Backstage passes to a TAFKAL80ETC concert":
                    return(BackstagePass.Build(item.SellIn));

                case "Aged Brie":
                    return(AgedBrie.Build(item.SellIn));

                case "Conjured Mana Cake":
                    return(Conjured.Build(item.SellIn));

                default:
                    return(Generic.Build(item.SellIn));
                }
            }
Ejemplo n.º 3
0
        public void Conjured_roses_degrade_in_Quality_twice_as_fast_as_normal_roses()
        {
            var          rose  = new Conjured(10, 20);
            IList <Rose> roses = new List <Rose> {
                rose
            };

            GildedRose gildedRose = new GildedRose(roses);

            for (var i = 0; i < 5; i++)
            {
                gildedRose.UpdateQuality();
            }

            var roseAfterFiveDays = new Rose("Conjured Mana Cake", 5, 10);

            Assert.True(roseAfterFiveDays.Equals(rose));
        }
Ejemplo n.º 4
0
        private int NewQuality(Item item)
        {
            if (item.Name == "Sulfuras, Hand of Ragnaros")
            {
                return(item.Quality);
            }

            if (item.Name == "Aged Brie")
            {
                var brie = new Brie();
                return(brie.NewQuality(item));
            }

            if (item.Name == "Sulfuras")
            {
                var sulfuras = new Sulfuras();
                return(sulfuras.NewQuality(item));
            }

            if (item.Name == "Backstage passes to a TAFKAL80ETC concert")
            {
                var backstagePass = new BackstagePass();
                return(backstagePass.NewQuality(item));
            }

            if (item.Name.IndexOf("Conjured") == 0)
            {
                var conjured = new Conjured();
                return(conjured.NewQuality(item));
            }

            // other regular items
            var regular = new Regular();

            return(regular.NewQuality(item));
        }