Exemple #1
0
 public void InitializeOriginRose()
 {
     originRose = new Rose();
     originRose.size = 2f;
     originRose.position = new Vector3(0, 0, 0);
     originRose.roseState = Rose.RoseState.isInUse;
 }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Problem logs: ");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * Problem:
             * Class Flower doesn't work without Electricity and Lamp Classes.
             * And if I want to change Lamp to another class (ex. Sun),
             * that mean I need to modify Flower class
             * (which doesn't recommended by Open-Closed Principle)
             *
             * Also if I want to test Flower class with simulation of light (mock lamp)
             * I can't do this.
             */
            var myFlower = new Flower();

            myFlower.StartPhotosynthesis();

            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Fabric method logs:");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * We pulled the water object out of the Rose class
             * That mean if I want to use mockWater, I can use WaterFactory for that
             */
            var myRoses = new Rose();

            myRoses.StartGrowing();

            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Add abstraction logs:");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * I implemented Dependency Injection Principle:
             * High-level Sunflower not depend on Low-level Sun
             * Both depend on Interface
             */

            var myShinySunflower = new Sunflower();

            myShinySunflower.Shining();

            Console.WriteLine("---------------------------------------");
            Console.WriteLine("Use Injector class:");
            Console.WriteLine("---------------------------------------");

            /* As far as I understand:
             * Injector class decline coupling between Poppy (Some Business Logic) and Wind (Data Source)
             */

            var myLovelyPoppy = new PoppyService();

            myLovelyPoppy.Disperse();
        }
Exemple #3
0
    private void Entry()
    {
        Rose  rose  = new Rose();
        Tulip tulip = new Tulip();

        rose.Printinfo();
        Console.WriteLine();
        tulip.Printinfo();
    }
Exemple #4
0
        /// <summary>
        /// Конструктор класса <see cref="Rose"/>
        /// </summary>
        public static void DefRose()
        {
            Rose rose = new Rose();

            rose.Name  = "Французская роза";
            rose.Size  = 10.5;
            rose.Color = (Colors)1;
            Console.WriteLine($"Роза\nНазвание: {rose.Name}\nРазмер: {rose.Size}\nЦвет: {rose.Color}\n");
        }
        protected void SeedData(InheritanceContext context)
        {
            var kiwi = new Kiwi
            {
                Species      = "Apteryx haastii",
                Name         = "Great spotted kiwi",
                IsFlightless = true,
                FoundOn      = Island.South
            };

            var eagle = new Eagle
            {
                Species = "Aquila chrysaetos canadensis",
                Name    = "American golden eagle",
                Group   = EagleGroup.Booted
            };

            eagle.Prey.Add(kiwi);

            var rose = new Rose
            {
                Species   = "Rosa canina",
                Name      = "Dog-rose",
                HasThorns = true
            };

            var daisy = new Daisy
            {
                Species = "Bellis perennis",
                Name    = "Common daisy"
            };

            var nz = new Country {
                Id = 1, Name = "New Zealand"
            };

            nz.Animals.Add(kiwi);

            var usa = new Country {
                Id = 2, Name = "USA"
            };

            usa.Animals.Add(eagle);

            context.Set <Animal>().Add(kiwi);
            context.Set <Bird>().Add(eagle);
            context.Set <Country>().Add(nz);
            context.Set <Country>().Add(usa);
            context.Set <Rose>().Add(rose);
            context.Set <Daisy>().Add(daisy);

            context.SaveChanges();
        }
Exemple #6
0
        /// <summary>
        ///  <para>Работа с объектом через ссылку на интерфейс и абстрактный класс</para>
        ///  <para>Работа is и as</para>
        /// </summary>
        public static void ObjViaRefInterface()
        {
            IPaper paper = new Bouquet();

            paper.Color = "Зеленый";
            Console.WriteLine($"\nЦвет: {paper.Color}");
            paper.Note();

            Plant plant = new Bouquet();

            plant.Name = "Ромашка";
            Console.WriteLine($"\nНазвание: {plant.Name}");
            plant.Note();

            Plant plant1 = new Rose();

            plant1.Name = "Роза";
            plant1.Size = 2.43;
            Console.WriteLine($"\nНазвание: {plant1.Name}\nРазмер: {plant1.Size}");
            plant1.Note();
            Console.WriteLine($"{plant1.ToString()}");

            Flower  flower  = new Flower();
            Bouquet bouquet = new Bouquet();

            int num = 2;
            //bool checkFlower = flower is Flower;
            //bool checkBouquet = bouquet is Bouquet;
            //bool checkNum = num is Flower;

            bool checkFlower  = bouquet is Flower;
            bool checkBouquet = flower is Bouquet;

            Console.WriteLine($"\ncheckFlower: {checkBouquet}\ncheckBouquet: {checkFlower}\ncheckNum:");


            try
            {
                Flower flower1 = new Flower();
                Rose   rose    = flower1 as Rose;
                Console.WriteLine($"\n{rose.GetType()}");
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e);
            }

            Rose   rose1   = new Rose();
            Flower flower2 = rose1 as Flower;

            Console.WriteLine($"\n{flower2.GetType()}");
        }
Exemple #7
0
        private static void FunctionTemplatingExample()
        {
            Console.WriteLine(FunctionTemplating.Equals(1, 1));
            Console.WriteLine(FunctionTemplating.Equals("abc", "xyz"));
            var dog   = new Dog();
            var cat   = new Cat();
            var horse = new Horse();
            var rose  = new Rose();

            Console.WriteLine(FunctionTemplating.Equals(dog, dog));

            FunctionTemplating.SomeFunction(dog, dog, cat);
        }
        public void CheckoutFunction_MultipleFlowersAtOnce()
        {
            var rose     = new Rose(_rosePrice, 20);
            var orchid   = new Orchid(_orchidPrice, 10);
            var gladioli = new Gladioli(_gladioliPrice, 5);
            var rose2    = new Rose(_rosePrice, 8);

            var flowers = new List <Flower> {
                rose, orchid, gladioli, rose2
            };

            _paymentFlower.CheckOut(flowers);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            var rose       = new Rose("red", "John", "Kovalsky");
            var clonedRose = rose.Clone();

            Console.WriteLine($"Original's owner: {rose.Owner.FullName}, \tcopy's owner: {clonedRose.Owner.FullName}");

            clonedRose.Owner.FirstName = "Ana";

            Console.WriteLine($"Original's owner: {rose.Owner.FullName}, \tcopy's owner: {clonedRose.Owner.FullName}");

            Console.Read();
        }
        public void CheckoutFunction_SingleFlower()
        {
            var rose = new Rose(_rosePrice, 1);

            _paymentFlower.CheckOut(rose);

            var orchid = new Orchid(_orchidPrice, 10);

            _paymentFlower.CheckOut(orchid);

            var orchid2 = new Orchid(_orchidPrice, 2);

            _paymentFlower.CheckOut(orchid2);
        }
Exemple #11
0
        static void Main(string[] args)
        {
            var Flower1 = new Iris("Pink", 20);
            var Flower2 = new Pion("Red", 22);
            var Flower3 = new Rose("Pink", 78);
            var Flower4 = new Iris("Blue", 23);
            var Flower5 = new Scaevola("Blue", 67);

            var Bouquet = new Bouquet(Flower1, Flower2, Flower3, Flower4, Flower5);

            System.Console.WriteLine("Bouquet information");

            Bouquet.BouqetInfo();
        }
Exemple #12
0
        static void Main(string[] args)
        {
            Printer print = new Printer();
            Plant   p1    = new Rose(25, "red") as Rose;

            print.IAmPrinting(p1);
            Console.WriteLine("\n");
            Plant p2 = new Gladiolus(100, "green");

            print.IAmPrinting(p2);
            Plant p3 = new Cactus(1231, "black");

            Plant[] arr = new Plant[2];
            arr[0] = p1;
            arr[1] = p2

                     foreach (Plant item in arr)
            {
                Console.WriteLine("----------------------------------------------------------------");
                print.IAmPrinting(item);
            }


            Container b = new Container();

            b.byk = new List <Plant>();
            b.Add(p3);
            b.Add(p2);
            b.Add(p1);
            Console.WriteLine("\n");
            Console.WriteLine("\n");
            b.Info();

            b.PriceOfFlowers();

            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Console.WriteLine("----------------------------------------------------------------");
            Controller cont = new Controller();

            cont.Search(b.byk);
            cont.PriceSorting(b.byk);
            b.Info();
        }
Exemple #13
0
        public void TestPriceRose()
        {
            //тест 0: для роз на скидке
            Rose rose0     = new Rose(86, Freshness.SaleFreshness, 27);
            int  expected0 = 78; //86-8=78
            int  actual0   = rose0.Price;

            Assert.AreEqual(expected0, actual0);

            //тест 1: для роз плохого качества
            Rose rose1     = new Rose(86, Freshness.LowFreshness, 27);
            int  expected1 = 80; //86-6=80
            int  actual1   = rose1.Price;

            Assert.AreEqual(expected1, actual1);

            //тест 2: для роз ниже среднего качества
            Rose rose2     = new Rose(87, Freshness.BelowAverageFreshness, 30);
            int  expected2 = 83; //87-4=83
            int  actual2   = rose2.Price;

            Assert.AreEqual(expected2, actual2);

            //тест 3: для роз среднего качества
            Rose rose3     = new Rose(86, Freshness.MediumFreshness, 27);
            int  expected3 = 83; //86-3=83
            int  actual3   = rose3.Price;

            Assert.AreEqual(expected3, actual3);

            //тест 4: для роз выше среднего качества
            Rose rose4     = new Rose(94, Freshness.AboveAverageFreshness, 33);
            int  expected4 = 93; //94-1=93
            int  actual4   = rose4.Price;

            Assert.AreEqual(expected4, actual4);

            //тест 5: для роз наилучшего качества
            Rose rose5     = new Rose(86, Freshness.HighestFreshness, 27);
            int  expected5 = 86;
            int  actual5   = rose5.Price;

            Assert.AreEqual(expected5, actual5);
        }
Exemple #14
0
        public void InitializeRoseList()
        {
            while (roseList.Count < 36)
            {
                Rose rose = new Rose();
                rose.size = .1f;
                rose.position = RandomPosition(random.Next(36));
                //rose.playerCanLandOnFlower = false;

                bool addRose = true;

                foreach (Rose existingRose in roseList)
                {
                    if (rose.position == existingRose.position) addRose = false;
                }

                if (addRose) roseList.AddLast(rose);
            }
        }
Exemple #15
0
 public void OnTriggerExit(Collider otherObject)
 {
     if (otherObject.gameObject.name == "Well")
     {
         wellZone = false;
     }
     if (otherObject.gameObject.GetComponent <WhiteFlower>())
     {
         whiteFlower = null;
     }
     if (otherObject.gameObject.GetComponent <Mushroom>())
     {
         mushRoom = null;
     }
     if (otherObject.gameObject.GetComponent <SunflowerScript>())
     {
         sunFlower = null;
     }
     if (otherObject.gameObject.GetComponent <Rose>())
     {
         rose = null;
     }
 }
Exemple #16
0
        /// <summary>
        /// Проверка метода <c><see cref="Printer.IAmPrinting(Plant)"/></c>
        /// </summary>
        public static void CheckMethod()
        {
            Shrub shrub = new Shrub();

            shrub.Name = "Куст";
            shrub.Size = 50;

            Printer.IAmPrinting(shrub);

            Flower flower = new Flower();

            flower.Name = "Василек";
            flower.Size = 7;

            Printer.IAmPrinting(flower);

            Rose rose = new Rose();

            rose.Name  = "Французская роза";
            rose.Size  = 10.5;
            rose.Color = (Colors)1;

            Printer.IAmPrinting(rose);
        }
        static void Main(string[] args)
        {
            ulong  cases;
            string input;

            do
            {
                Console.Write("Choose the task: \n1) Trapezoid \n2) Circles \n3) Figures \n4) Furniture store \n5) Flowers \n6) Exit \nYour choice: ");
                input = Console.ReadLine();
                Validation.Ulong_Digits_check(input, out cases);
                switch (cases)
                {
                case 1:

                    Trapezoid   trus         = new Trapezoid(new Point(1, 1), new Point(2, 5), new Point(7, 5), new Point(8, 1));
                    Trapezoid   balbes       = new Trapezoid(new Point(3, 9), new Point(4, 11), new Point(5, 11), new Point(6, 9));
                    Trapezoid   byvalyi      = new Trapezoid(new Point(10, 9), new Point(11, 10), new Point(13, 10), new Point(14, 9));
                    Trapezoid   zhmyx1       = new Trapezoid(new Point(11, 3), new Point(13, 6), new Point(16, 6), new Point(18, 3));
                    double      midAreaValue = (trus.Area() + balbes.Area() + byvalyi.Area() + zhmyx1.Area()) / 4;
                    Trapezoid[] arr          = new Trapezoid[4];
                    arr[0] = trus;
                    arr[1] = balbes;
                    arr[2] = byvalyi;
                    arr[3] = zhmyx1;
                    int amount = 0;
                    foreach (Trapezoid value in arr)
                    {
                        if (value.Area() > midAreaValue)
                        {
                            amount++;
                        }
                    }
                    Console.WriteLine($"The side of first trapezoid is {trus.Perimeter()},\n sides of this trapezoid: {trus.TopLine}, {trus.BotLine}, {trus.Side1}, {trus.Side2},\n area: {trus.Area()}, middle line: {trus.MidLine},\n is Trapezoid right? {trus.AreEqual()}. Amount of bigger than middle area value: {amount}\n");

                    break;


                case 2:
                    Circle centralCircle = new Circle(new Point(0, 0), 12);
                    Circle outsideCircle = new Circle(new Point(3, 5), 11);
                    Console.WriteLine($"The radius of the circle with center int the point ({centralCircle.Center.X};{centralCircle.Center.Y}) is {centralCircle.Radius} circle length: {centralCircle.Length},\ncircle area: {centralCircle.Area}, is equal to circle with center in ({outsideCircle.Center.X};{outsideCircle.Center.Y})? {Circle.Compare(centralCircle, outsideCircle)}\n");
                    break;

                case 3:
                    Triangle  triangle  = new Triangle(3, 4, 5);
                    Ring      ring      = new Ring(4);
                    Rectangle rectangle = new Rectangle(4, 6);
                    Square    square    = new Square(3);
                    Ellipse   ellipse   = new Ellipse(4.5, 3.3);

                    Figure[] figuresBox = new Figure[] { triangle, ring, square, ellipse, rectangle };
                    foreach (Figure value in figuresBox)
                    {
                        value.ShowInfo();
                    }
                    break;

                case 4:
                    int deletable;
                    List <Furniture> furnitureList = new List <Furniture>();
                    List <Material>  materialList  = new List <Material>();

                    Furniture desk           = new Furniture("table", "redwood", 4, 40, "GLEk_inc");
                    Furniture hotchair       = new Furniture("chair", "yellow", 1, 15, "GLEk_inc");
                    Furniture kresloDlyaBaty = new Furniture("sofa", "green", 1.5, 47.5, "Batya industries");

                    Material wood = new Material(500, 10000);
                    Material weed = new Material(15, 2000);

                    furnitureList.Add(desk);
                    furnitureList.Add(kresloDlyaBaty);
                    furnitureList.Add(hotchair);

                    materialList.Add(weed);
                    materialList.Add(wood);

                    Console.Write("Delete material №: ");
                    input = Console.ReadLine();
                    Validation.ListCountCheck(input, out deletable, materialList.Count);
                    materialList.RemoveAt(deletable - 1);

                    Console.Write("Delete furniture №: ");
                    input = Console.ReadLine();
                    Validation.ListCountCheck(input, out deletable, furnitureList.Count);
                    furnitureList.RemoveAt(deletable - 1);

                    Console.WriteLine("View furniture");
                    foreach (Furniture s in furnitureList)
                    {
                        Console.WriteLine(s.FurnitureType + "\n");
                    }

                    Console.WriteLine("View material");
                    foreach (Material s in materialList)
                    {
                        Console.WriteLine(s.Cost + "\n");
                    }
                    break;

                case 5:
                    double cost = 0;

                    object[] bouquet = new Flower[5];

                    bouquet[0] = new Rose("yellow");
                    bouquet[1] = new Carnation("blue");
                    bouquet[2] = new Tulip("white");
                    bouquet[3] = new Tulip("blue");
                    bouquet[4] = new Rose("red");

                    foreach (Flower s in bouquet)
                    {
                        cost = cost + s.Cost;
                    }

                    Console.WriteLine($"This bouquet costs {cost} c.u. \n");
                    break;

                case 6:
                    return;

                default:
                    Console.WriteLine("Error. Choose the menu item again.\n");
                    break;
                }
            } while (true);
        }
Exemple #18
0
        public void ShowMainMenu()
        {
            Console.WriteLine(
                "\n\t FlowerSet Creation Main Menu" +
                "\n\t___________________________________________________________________" +
                "\n\n\t To see list of available flowers - click on button 1" +
                "\n\t To add flower/flowers to Flowerset - click on button 2" +
                "\n\t To review your FlowerSet - click on button 3" +
                "\n\t To find flowers in FlowerSet by price range - click on button 4" +
                "\n\t To sort your FlowerSet by price - click on button 5" +
                "\n\t To delete flower/flowers from FlowerSet - click on button 6" +
                "\n\t To remove All flowers from FlowerSet - click on button 7" +
                "\n\t To review total price of the FlowerSet - click on button 8" +
                "\n\t To exit - enter q" +
                ""
                );
            string sign = Console.ReadLine();

            try
            {
                switch (sign)
                {
                case "1":
                    Console.Clear();
                    DisplayAvailableFlowers();
                    ShowMainMenu();
                    break;

                case "2":
                    Console.Clear();
                    Console.WriteLine("Flower Addition to Flower Set");
                    Console.WriteLine("Enter flower name:");
                    string fn = Convert.ToString(Console.ReadLine());
                    Console.WriteLine("How many flowers to add:");
                    int c = Convert.ToInt32(Console.ReadLine());
                    if (fn == "Rose")
                    {
                        Console.WriteLine("Rose of what size do you want to add (10, 20, 30, 40, 50 are available):");
                        int    l    = Convert.ToInt32(Console.ReadLine());
                        Flower rose = new Rose(fn, l);
                        flSet.AddFlowerToFlowerCollection(rose, c);
                    }
                    else
                    {
                        Type t = Type.GetType("FlowerShop.Flowers." + fn);

                        Flower flowerclass = (Flower)Activator.CreateInstance(t, fn);
                        flSet.AddFlowerToFlowerCollection(flowerclass, c);
                    }
                    Console.WriteLine("\tReporting:  " + c + " flower/flowers added");
                    ShowMainMenu();
                    break;

                case "3":
                    Console.Clear();
                    Console.WriteLine("Review the Flower Set");
                    flSet.DisplayFlowerNamesAndPriceAndQuantity();
                    ShowMainMenu();
                    break;

                case "4":
                    Console.Clear();
                    Console.WriteLine("Range flowers by price");
                    if (!flSet.CheckFlowersInCollection())
                    {
                        ShowMainMenu();
                        break;
                    }
                    Console.WriteLine("Enter min price:");
                    double min = Convert.ToDouble(Console.ReadLine());
                    Console.WriteLine("Enter max price:");
                    double max = Convert.ToDouble(Console.ReadLine());
                    flSet.FindFlowerinFlowerSetByPrice(min, max);
                    ShowMainMenu();
                    break;

                case "5":
                    Console.Clear();
                    Console.WriteLine("Sort flowers in Flower Set by price");
                    flSet.SortFlowersInFlowerSetByPrice();
                    ShowMainMenu();
                    break;

                case "6":
                    Console.Clear();
                    if (!flSet.CheckFlowersInCollection())
                    {
                        ShowMainMenu();
                        break;
                    }
                    Console.WriteLine("Flower Deletion");
                    Console.WriteLine("Enter flower name:");
                    string fln = Convert.ToString(Console.ReadLine());
                    Console.WriteLine("How many flowers to delete:");
                    int cou = Convert.ToInt32(Console.ReadLine());

                    if (fln == "Rose")
                    {
                        Console.WriteLine("Rose of what size do you want to delete:");
                        int l = Convert.ToInt32(Console.ReadLine());
                        flSet.DeleteFlowerFromFlowerCollection(fln, cou, l);
                    }
                    else
                    {
                        flSet.DeleteFlowerFromFlowerCollection(fln, cou);
                    }
                    ShowMainMenu();
                    //ADD exception  если длина розы не та!!!!!!!!!!!!!!!!! и нет достаточно цветов
                    break;

                case "7":
                    Console.Clear();
                    Console.WriteLine("All flowers removal");
                    flSet.RemoveAllFlowersFromFlowerCollection();
                    ShowMainMenu();
                    break;

                case "8":
                    Console.Clear();
                    Console.WriteLine("Review Total Price");
                    flSet.DisplayTotalPrice();
                    ShowMainMenu();
                    break;

                case "q":
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                ShowMainMenu();
            }
        }
 public MediumBouchet()
 {
     Rose     = new Rose(10, 6);
     Gladioli = new Gladioli(15, 3);
 }
Exemple #20
0
        private void btn_Rose_Click(object sender, RoutedEventArgs e)
        {
            Rose rose = new Rose();

            rose.Show();
        }
Exemple #21
0
 public bool Equals(Rose other)
 {
     return(Name == other.Name && SellIn == other.SellIn && Quality == other.Quality);
 }
Exemple #22
0
 public BigBouchet()
 {
     Rose     = new Rose(10, 20);
     Orchid   = new Orchid(30, 10);
     Gladioli = new Gladioli(15, 5);
 }
Exemple #23
0
 public SmallBouchet()
 {
     Rose = new Rose(10, 5);
 }
Exemple #24
0
 public static void StartGame(string userAnswer)
 {
     Rose.QuestionAnswered(userAnswer);
     Main();
 }