Esempio n. 1
0
        async Task ExecuteLoadDogsCommand()
        {
            IsBusy = true;

            try
            {
                if (Dogs.Count() > 0)
                {
                    return;
                }

                var dogs = await DogStore.GetItemsAsync(true);

                foreach (var dog in dogs)
                {
                    Dogs.Add(dog);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void AddAnimal()
        {
            Console.Clear();
            Menus.PrintMammals();
            var input = Console.ReadKey(true).Key;

            switch (input)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                Dog newDog = new ArvochPolymorfism3.Dog();
                Console.WriteLine("Name: ");
                newDog.Name = Console.ReadLine();

                Console.WriteLine("Weight: ");
                newDog.Weight = int.Parse(Console.ReadLine());

                Console.WriteLine("Age: ");
                newDog.Age = int.Parse(Console.ReadLine());

                Console.WriteLine("Tail Length: ");
                newDog.TailLength = int.Parse(Console.ReadLine());

                Console.WriteLine("Does the dog have fur?");
                string hasFurController = Console.ReadLine();

                if (hasFurController == "y")
                {
                    newDog.HasFur = true;
                }
                else
                {
                    newDog.HasFur = false;
                }

                Dogs.Add(newDog);
                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                Console.Clear();
                Menus.PrintInsects();
                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                Console.Clear();
                Menus.PrintBirds();
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                Console.Clear();
                Menus.PrintReptiles();
                break;
            }
        }
Esempio n. 3
0
        public ViewModel()
        {
            Humen.CollectionChanged += Any_CollectionChanged;
            Dogs.CollectionChanged  += Any_CollectionChanged;

            Humen.Add(new Human("Jake", Colors.Green));
            Humen.Add(new Human("Tim", Colors.Blue));
            Humen.Add(new Human("Lisa", Colors.Pink));

            Dogs.Add(new Dog("Rex", Colors.Blue));
            Dogs.Add(new Dog("Daisy", Colors.Pink));
            Dogs.Add(new Dog("Snoopy", Colors.AliceBlue));
        }
Esempio n. 4
0
        public void AddAnimal()
        {
            Console.Clear();
            Menus.PrintAnimalTypes();

            var input = Console.ReadKey(true).Key;

            switch (input)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                Console.Clear();
                Menus.PrintMammals();

                Dog newDog = new Dog();
                Console.Write("Name: ");
                newDog.Name = Console.ReadLine();

                Console.Write("Age: ");
                newDog.Age = int.Parse(Console.ReadLine());

                Console.Write("Weight: ");
                newDog.Weight = int.Parse(Console.ReadLine());

                Console.Write("Tail length: ");
                newDog.TailLength = int.Parse(Console.ReadLine());

                Dogs.Add(newDog);

                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                Console.Clear();
                Menus.PrintInsects();
                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                Console.Clear();
                Menus.PrintReptiles();
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                Console.Clear();
                Menus.PrintBirds();
                break;
            }
        }
        public void Add(Animal a)
        {
            a.Order = order;
            order++;

            if (a is Dog)
            {
                Dogs.Add(a as Dog);
            }
            if (a is Cat)
            {
                Cats.Add(a as Cat);
            }
        }
Esempio n. 6
0
        public MainPageViewModel()
        {
            Dogs.Add(new Dog()
            {
                Name = "Mario", Photo = "dog.jpg"
            });
            Dogs.Add(new Dog()
            {
                Name = "Carlos", Photo = "dog2.jpg"
            });

            DeleteCommand = new Command <Dog>((obj) =>
            {
                Dogs.Remove(obj);
            });
        }
Esempio n. 7
0
        public MainWindow()
        {
            InitializeComponent();

            for (int i = 0; i < 10; i++)
            {
                Dogs.Add(new Dog()
                {
                    Name = "Dog" + i
                });

                Cats.Add(new Cat()
                {
                    Name = "Cat" + i
                });
            }

            DataContext = this;
        }