Пример #1
0
        public void EnumToListExtension()
        {
            Fruits basket = Fruits.Banana;

            basket = basket.Add(Fruits.Pineapple);
            basket = basket.Add(Fruits.Durian);
            var members = (List <Fruits>)basket.ToList <Fruits>();

            Assert.Equal(3, members.Count);
        }
Пример #2
0
 public EventToCommandPageViewModel()
 {
     Fruits.Add(new Fruit {
         Name = "Apple", Color = Color.Red
     });
     Fruits.Add(new Fruit {
         Name = "Orange", Color = Color.Orange
     });
     Fruits.Add(new Fruit {
         Name = "Pineapple", Color = Color.Yellow
     });
     Fruits.Add(new Fruit {
         Name = "Banana", Color = Color.Yellow
     });
     Fruits.Add(new Fruit {
         Name = "Peach", Color = Color.Pink
     });
     Fruits.Add(new Fruit {
         Name = "Mango", Color = Color.Yellow
     });
     Fruits.Add(new Fruit {
         Name = "Melon", Color = Color.Green
     });
     Fruits.Add(new Fruit {
         Name = "Grape", Color = Color.Purple
     });
     Fruits.Add(new Fruit {
         Name = "Strawberry", Color = Color.Red
     });
 }
Пример #3
0
        public void AddNewFruit()
        {
            Fruits.Add(new Fruit(NewFruitName, NewFruitColor));

            NewFruitName  = "";
            NewFruitColor = "";
        }
Пример #4
0
        public ViewModel()
        {
            this.Fruits = new ObservableCollection <Model>();

            Fruits.Add(new Model()
            {
                FruitName = "Apple", People = 27
            });
            Fruits.Add(new Model()
            {
                FruitName = "Orange", People = 33
            });
            Fruits.Add(new Model()
            {
                FruitName = "Grapes", People = 15
            });
            Fruits.Add(new Model()
            {
                FruitName = "Banana", People = 5
            });
            Fruits.Add(new Model()
            {
                FruitName = "Blueberry", People = 20
            });
        }
 /// <summary>
 /// Initialize Instance.
 /// </summary>
 public FruitsListPageViewModel()
 {
     Fruits.Add(new Fruit {
         Name = "Apple", Color = Color.Red
     });
     Fruits.Add(new Fruit {
         Name = "Orange", Color = Color.Orange
     });
     Fruits.Add(new Fruit {
         Name = "Pineapple", Color = Color.Orange
     });
     Fruits.Add(new Fruit {
         Name = "Banana", Color = Color.Goldenrod
     });
     Fruits.Add(new Fruit {
         Name = "Peach", Color = Color.DeepPink
     });
     Fruits.Add(new Fruit {
         Name = "Mango", Color = Color.Goldenrod
     });
     Fruits.Add(new Fruit {
         Name = "Melon", Color = Color.Green
     });
     Fruits.Add(new Fruit {
         Name = "Grape", Color = Color.Purple
     });
     Fruits.Add(new Fruit {
         Name = "Strawberry", Color = Color.Red
     });
 }
Пример #6
0
 public ClearSelectedItemAttachedPropertyPageViewModel()
 {
     Fruits.Add(new Fruit {
         Name = "Apple", Color = Color.Red
     });
     Fruits.Add(new Fruit {
         Name = "Orange", Color = Color.Orange
     });
     Fruits.Add(new Fruit {
         Name = "Pineapple", Color = Color.Yellow
     });
     Fruits.Add(new Fruit {
         Name = "Banana", Color = Color.Yellow
     });
     Fruits.Add(new Fruit {
         Name = "Peach", Color = Color.Pink
     });
     Fruits.Add(new Fruit {
         Name = "Mango", Color = Color.Yellow
     });
     Fruits.Add(new Fruit {
         Name = "Melon", Color = Color.Green
     });
     Fruits.Add(new Fruit {
         Name = "Grape", Color = Color.Purple
     });
     Fruits.Add(new Fruit {
         Name = "Strawberry", Color = Color.Red
     });
 }
Пример #7
0
        public ViewModel()
        {
            this.Fruits = new ObservableCollection <Model>();

            Fruits.Add(new Model()
            {
                FruitName = "Apple", People = 27, Size = 0.3m
            });
            Fruits.Add(new Model()
            {
                FruitName = "Orange", People = 33, Size = 0.2m
            });
            Fruits.Add(new Model()
            {
                FruitName = "Grapes", People = 15, Size = 0.2m
            });
            Fruits.Add(new Model()
            {
                FruitName = "Banana", People = 5, Size = 0.3m
            });
            Fruits.Add(new Model()
            {
                FruitName = "Blueberry", People = 20, Size = 0.4m
            });
        }
Пример #8
0
 private void OnAppearing()
 {
     Fruits.Clear();
     Fruits.Add("Strawberry");
     Fruits.Add("Apple");
     Fruits.Add("Banana");
     Fruits.Add("Orange");
 }
Пример #9
0
        public void EnumAddAndContainsExtension()
        {
            Fruits basket = Fruits.Banana;

            basket = basket.Add(Fruits.Pineapple);
            Assert.True(basket.Contains(Fruits.Banana));
            Assert.True(basket.Contains(Fruits.Pineapple));
            Assert.False(basket.Contains(Fruits.Durian));
        }
Пример #10
0
        public MainContext(DbContextOptions <MainContext> options) : base(options)
        {
            if (!Dishes.Any())
            {
                Dishes.Add(new Dish()
                {
                    Name = "Plate"
                });
                Dishes.Add(new Dish()
                {
                    Name = "Fork"
                });
                Dishes.Add(new Dish()
                {
                    Name = "Knife"
                });
                SaveChanges();
            }

            if (!Fruits.Any())
            {
                Fruits.Add(new Fruit()
                {
                    Name = "Apple"
                });
                Fruits.Add(new Fruit()
                {
                    Name = "Orange"
                });
                Fruits.Add(new Fruit()
                {
                    Name = "Kiwi"
                });
                SaveChanges();
            }

            if (!Vegetables.Any())
            {
                Vegetables.Add(new Vegetable()
                {
                    Name = "Cucumber"
                });
                Vegetables.Add(new Vegetable()
                {
                    Name = "Tomato"
                });
                Vegetables.Add(new Vegetable()
                {
                    Name = "Carrot"
                });
                SaveChanges();
            }
        }
        public void populateComboBoxes()
        {
            //Populate Both ComboBoxes
            DataAccess db = new DataAccess();

            foreach (var item in db.GetAllFruits())
            {
                Fruits.Add(item.Name + " " + item.Color);
            }
            foreach (var item in db.GetAllPlanets())
            {
                Planets.Add(item.Name2 + " " + item.Color2);
            }
        }
Пример #12
0
        private void LoadFruits(XDocument doc)
        {
            var elemList = doc.Descendants("Fruit");
            int x, y, sx, sy;

            foreach (var item in elemList)
            {
                int.TryParse(item.Attribute("X").Value, out x);
                int.TryParse(item.Attribute("Y").Value, out y);
                int.TryParse(item.Attribute("SizeX").Value, out sx);
                int.TryParse(item.Attribute("SizeY").Value, out sy);
                Fruits.Add(new Fruit {
                    X = x, Y = y, SizeX = sx, SizeY = sy
                });
            }
        }
        private void OnAppearing()
        {
            Fruits.Clear();
            Fruits.Add("Apple");
            Fruits.Add("Orange");
            Fruits.Add("Banana");
            Fruits.Add("Pineapple");
            Fruits.Add("Pear");
            Fruits.Add("Grapes");

            //**DEBUG HERE**
            //HERE THE POSITION = 0 BUT VISUALLY THE CAROUSEL DIFFERS.
            var position = FruitPosition;

            //**DEBUG HERE**
            //ON FIRST INSTANCE SELECTEDFRUIT IS NULL. IT SHOULD BE
            //SET TO APPLE. ON SUBSEQUANT RUNS IT REMAINS APPLE BUT
            //VISUALLY THE CAROUSEL DIFFERS.
            var selectedFruit = CurrentFruit;
        }
Пример #14
0
        /// <summary>
        /// Handles The Random Spawns of fruits when the player score is added 1200 points
        /// </summary>
        private void SpawnFruit()
        {
            int          type;
            List <Point> availablePositions = new List <Point>();

            string[] file = File.ReadAllLines($@"{Content.RootDirectory}\board.txt");

            int width  = file[0].Length;
            int height = file.Length;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    switch (file[y][x])
                    {
                    case ' ':
                        availablePositions.Add(new Point(x, y));
                        break;
                    }
                }
            }

            int chance = Rnd.Next(0, 100);

            if (chance <= 50)
            {
                type = 0;
            }
            else if (chance <= 75)
            {
                type = 1;
            }
            else if (chance <= 90)
            {
                type = 2;
            }
            else if (chance <= 98)
            {
                type = 3;
            }
            else
            {
                type = 4;
            }

            int   index    = Rnd.Next(availablePositions.Count);
            Point position = availablePositions[index];

            PacDot dot = PacDots.FirstOrDefault(p => p.Position == position);

            if (dot != null)
            {
                PacDots.Remove(dot);
                Components.Remove(dot);
            }

            Fruit fruit = new Fruit(this, position, type);

            Fruits.Add(fruit);
            Components.Add(fruit);
        }
 public void AddNewFruit(string name, Color color)
 {
     Fruits.Add(new Fruit(name, color));
 }
Пример #16
0
        public void GenerateFruits()
        {
            foreach (Fruit fruit in Fruits)
            {
                if (!(GameMap.MapUnits[fruit.UnitPosition.Row, fruit.UnitPosition.Column] is Snake))
                {
                    GameMap.RemoveUnit(fruit.UnitPosition);
                }
            }
            Fruits.Clear();

            Random random = new Random();
            int    aux    = random.Next(100);

            if (aux < 60) // place one fruit
            {
                bool canPut = false;
                while (!canPut)
                {
                    Random rdRow     = new Random();
                    Random rdColumn  = new Random();
                    int    auxRow    = rdRow.Next(GameMap.NumberOfRows);
                    int    auxColumn = rdColumn.Next(GameMap.NumberOfColumns);
                    if (GameMap.MapUnits[auxRow, auxColumn] == null &&
                        (((auxRow - SnakeParts[0].UnitPosition.Row) < -2) || ((auxRow - SnakeParts[0].UnitPosition.Row) > 2) ||
                         ((auxColumn - SnakeParts[0].UnitPosition.Column) < -2) || ((auxColumn - SnakeParts[0].UnitPosition.Column) > 2)))
                    {
                        GameMap.AddUnit(new Fruit(new Position(auxRow, auxColumn)));
                        Fruits.Add(new Fruit(new Position(auxRow, auxColumn)));
                        canPut = true;
                    }
                }
            }
            else // place two fruits
            {
                bool canPut = false;
                while (!canPut)
                {
                    Random rdRow1     = new Random();
                    Random rdColumn1  = new Random();
                    Random rdRow2     = new Random();
                    Random rdColumn2  = new Random();
                    int    auxRow1    = rdRow1.Next(GameMap.NumberOfRows);
                    int    auxColumn1 = rdColumn1.Next(GameMap.NumberOfColumns);
                    int    auxRow2    = rdRow2.Next(GameMap.NumberOfRows);
                    int    auxColumn2 = rdColumn2.Next(GameMap.NumberOfColumns);
                    if ((auxRow1 != auxRow2 || auxColumn1 != auxColumn2) &&
                        GameMap.MapUnits[auxRow1, auxColumn1] == null && GameMap.MapUnits[auxRow2, auxColumn2] == null &&
                        (((auxRow1 - SnakeParts[0].UnitPosition.Row) < -2) || ((auxRow1 - SnakeParts[0].UnitPosition.Row) > 2) ||
                         ((auxColumn1 - SnakeParts[0].UnitPosition.Column) < -2) || ((auxColumn1 - SnakeParts[0].UnitPosition.Column) > 2)) &&
                        (((auxRow2 - SnakeParts[0].UnitPosition.Row) < -2) || ((auxRow2 - SnakeParts[0].UnitPosition.Row) > 2) ||
                         ((auxColumn2 - SnakeParts[0].UnitPosition.Column) < -2) || ((auxColumn2 - SnakeParts[0].UnitPosition.Column) > 2)))
                    {
                        GameMap.AddUnit(new Fruit(new Position(auxRow1, auxColumn1)));
                        Fruits.Add(new Fruit(new Position(auxRow1, auxColumn1)));
                        GameMap.AddUnit(new Fruit(new Position(auxRow2, auxColumn2)));
                        Fruits.Add(new Fruit(new Position(auxRow2, auxColumn2)));
                        canPut = true;
                    }
                }
            }
        }
Пример #17
0
 /// <summary>
 /// Adds a fruit to the fruit cache.
 /// </summary>
 /// <param name="fruit">The given fruit.</param>
 public void Add(Fruit fruit) => Fruits.Add(fruit);