コード例 #1
0
    public void Start()
    {
        Screen.SetResolution(600, 550, false);
        EventHandler.ResetGame += hideGameOver;
        EventHandler.GameOver  += GameOver;
        gameScore = 0;

        Lion henk = Instantiate(lion, animalCollector.transform).GetComponent <Lion>();

        henk.name = "henk";
        Hippo elsa = Instantiate(hippo, animalCollector.transform).GetComponent <Hippo>();

        elsa.name = "elsa";
        Pig dora = Instantiate(pig, animalCollector.transform).GetComponent <Pig>();

        dora.name = "dora";
        Tiger wally = Instantiate(tiger, animalCollector.transform).GetComponent <Tiger>();

        wally.name = "wally";
        Zebra marty = Instantiate(zebra, animalCollector.transform).GetComponent <Zebra>();

        marty.name = "marty";
        Zebra mario = Instantiate(zebra, animalCollector.transform).GetComponent <Zebra>();

        mario.name = "mario";
        Dog lena = Instantiate(dog, animalCollector.transform).GetComponent <Dog>();

        lena.name = "lena";
        Panda wilco = Instantiate(panda, animalCollector.transform).GetComponent <Panda>();

        wilco.name = "wilco";

        StartCoroutine(foodSpawner());
        StartCoroutine(giveScore());
    }
コード例 #2
0
        public IActionResult PlaceBet(int betAmount, string betType)
        {
            string userId = _userManager.GetUserId(User);

            List <Zebra> list = context.Zebras //which zebra has right ssn? pull current data from persistant
                                               //.Include(z => z.SSN)
                                .Where(z => z.SSN == userId)
                                .ToList();

            user = list[0];

            if (betAmount <= user.Bank)
            {
                context.Zebras.Find(user.Id).Bank -= betAmount;
                context.SaveChanges();
                //user.Bank -= betAmount;
                Bet bet = new Bet
                {
                    Amount = betAmount,
                    Type   = betType
                };
                bets.Add(bet);
            }
            return(Redirect("/Roulette"));
        }
コード例 #3
0
        private Animal ExecuteOddCommand(string[] cmdArgs)
        {
            var animalType   = cmdArgs[0];
            var animalName   = cmdArgs[1];
            var animalWeight = double.Parse(cmdArgs[2]);
            var animalRegion = cmdArgs[3];

            switch (animalType)
            {
            case "Mouse":
                Mouse mouse = new Mouse(animalType, animalName, animalWeight, animalRegion);
                return(mouse);

            case "Tiger":
                Tiger tiger = new Tiger(animalType, animalName, animalWeight, animalRegion);
                return(tiger);

            case "Cat":
                var breed = cmdArgs[4];
                Cat cat   = new Cat(animalType, animalName, animalWeight, animalRegion, breed);
                return(cat);

            case "Zebra":
                Zebra zebra = new Zebra(animalType, animalName, animalWeight, animalRegion);
                return(zebra);

            default:
                return(null);
            }
        }
コード例 #4
0
    static void Main()
    {
        string[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        while (input[0] != "End")
        {
            string typeOfEnimal = input[0];//Cat,Zebra.....
            string animalName   = input[1];
            double weight       = Convert.ToDouble(input[2]);
            string livingRegion = input[3];

            string[] inputLineTwo = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

            string  typeOfFood   = inputLineTwo[0];
            int     quantityFood = int.Parse(inputLineTwo[1]);
            dynamic food         = null;
            switch (typeOfFood)
            {
            case "Vegetable":
                food = new Vegetable(quantityFood, typeOfFood);
                break;

            case "Meat":
                food = new Meat(quantityFood, typeOfFood);
                break;
            }

            switch (typeOfEnimal)
            {
            case "Cat":
                string animalBreed = input[4];
                Animal cat         = new Cat(animalName, typeOfEnimal, weight, food, livingRegion, animalBreed);
                cat.MakeSound();
                Console.WriteLine(cat.ToString());
                break;

            case "Tiger":

                Animal tiger = new Tiger(animalName, typeOfEnimal, weight, food, livingRegion);
                tiger.MakeSound();
                Console.WriteLine(tiger.TooString());
                break;

            case "Zebra":

                Mammal zebra = new Zebra(animalName, typeOfEnimal, weight, food, livingRegion);
                zebra.MakeSound();
                Console.WriteLine(zebra.TooString());


                break;

            case "Mouse":
                Mammal mouse = new Mouse(animalName, typeOfEnimal, weight, food, livingRegion);
                mouse.MakeSound();
                Console.WriteLine(mouse.TooString());
                break;
            }
            input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
コード例 #5
0
ファイル: Program.cs プロジェクト: luayyounus/OOP-Inheritance
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome the world of Inheritance!");

            Zoo seattleZoo = new Zoo();

            seattleZoo.SouvenirShop    = true;
            seattleZoo.NumberOfAnimals = 324;

            seattleZoo.Observe();

            Reptilia reptilia = new Reptilia();

            reptilia.DoActivity();

            SouthPacific southPacificAquaria = new SouthPacific();

            southPacificAquaria.Speed = 30;

            Console.Write("Setting speed and checking if it's a match then we found Nemo! - Result: ");
            southPacificAquaria.MatchWithNemo(30);

            Zebra someZebra = new Zebra();

            someZebra.CheckMinimumDangerLevel();

            Console.ReadLine();
        }
コード例 #6
0
        public static Animal GetAnimal(string[] animalTokens)
        {
            var typeOfAnimal = animalTokens[0];
            var name         = animalTokens[1];
            var weight       = double.Parse(animalTokens[2]);
            var livingRegion = animalTokens[3];

            switch (typeOfAnimal)
            {
            case "Mouse":
                Animal mouse = new Mouse(typeOfAnimal, name, weight, livingRegion);
                return(mouse);

            case "Zebra":
                Animal zebra = new Zebra(typeOfAnimal, name, weight, livingRegion);
                return(zebra);

            case "Tiger":
                Animal tiger = new Tiger(typeOfAnimal, name, weight, livingRegion);
                return(tiger);

            case "Cat":
                var    breed = animalTokens[4];
                Animal cat   = new Cat(typeOfAnimal, name, weight, livingRegion, breed);
                return(cat);
            }
            return(null);
        }
コード例 #7
0
        public static void Przesłanianie() // Nazewnictwo: nadpisanie/przesłanianie metody
        {
            /* Metoda która z założenia służy do tego, aby została przeszłonięta przez inna implementacje nazywamy metodą 'wirtualną'.
             * Więcej o metodzie wirtualnej i override w klasie 'Ssak' i 'Kon'.
             * Różnica pomiedzy 'Przesłonięciem'(ang. overriding) a 'Ukrywaniem'
             * Przesłonięcie metody polega na tym aby metoda wykonywała te same zadanie w sposób zależny od danej klasy.
             * Ukrycie metody - metody mogą wykonywać dwa całkowicie różne zadania. Ukrycie metody jest często błędem.
             */

            Ssak   ssak  = new Ssak();
            Kon    kon   = new Kon();
            Zebra  zebra = new Zebra();
            Delfin defin = new Delfin();


            /* Metoda wirtalna a 'polimorfizm'
             * Przy pomocy metod wirtualnych można wywoływać różne wersje tej samej metody w zależności od faktycznego typu obiektu przekazanego do zmiennej.
             * Typ obiektu może być tworzony dynamicznie, w trakcie działania programu.
             */
            // W klasie Ssak metoda Mowa() jest virtualna. Klasa Kon ją nadpisuje (override).
            ssak = kon;
            ssak.Mowa(); // Wykona się metoda z klasy Kon.

            ssak = zebra;
            ssak.Mowa(); // Wykona się metoda z klasy Zebra.

            // defin nie implementuje metody Mowa()
            ssak = defin;
            ssak.Mowa(); // Wykona się metoda z klasy Ssak.

            /*Note: Gdyby metoda Mowa() była ukryta a nie nadpisana to wykonałaby się metoda z klasy Ssak.
             * Jednak tak nie jest i na tym właśnie polaga polimorfizm (wiele form).
             */
        }
コード例 #8
0
        public static void Polimorfizm(int index)
        {
            Ssak ssak;

            switch (index)
            {
            case 1:
                ssak = new Kon();
                break;

            case 2:
                ssak = new Zebra();
                break;

            case 3:
                ssak = new Delfin();
                break;

            default:
                ssak = new Ssak();
                break;
            }

            ssak.Mowa();

            // Na podstawie podanego parametru mogę utworzyć różny obiek i za pomocą jednej instrukcji wykonać metodę zaimplementowaną w sposób zależny od klasy.
        }
コード例 #9
0
ファイル: Startup.cs プロジェクト: Dimitvp/OOP-Part1
        private static Mammal TryAnimalCreate(string animalType, string animalName, double animalWeight, string animalLivingRegion, string catBreed)
        {
            Mammal result = null;

            switch (animalType)
            {
            case "Mouse":
                result = new Mouse(animalName, animalType, animalWeight, animalLivingRegion);
                break;

            case "Zebra":
                result = new Zebra(animalName, animalType, animalWeight, animalLivingRegion);
                break;

            case "Cat":
                result = new Cat(animalName, animalType, animalWeight, animalLivingRegion, catBreed);
                break;

            case "Tiger":
                result = new Tiger(animalName, animalType, animalWeight, animalLivingRegion);
                break;
            }

            return(result);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: HotSpotSoft/Zebra
        public static int Main(string[] args)
        {
            Zebra zebra = new Zebra(args);

            zebra.Run();
            return(0);
        }
コード例 #11
0
        public void AreWhiteTigerAndZebraMonochrome()
        {
            WhiteTiger wtiger = new WhiteTiger();
            Zebra      zebra  = new Zebra();

            Assert.Equal(zebra.BlackOrWhite(), wtiger.BlackOrWhite());
        }
コード例 #12
0
        public IActionResult Index()//everything to display to user
        {
            string userId = _userManager.GetUserId(User);

            List <Zebra> list = context.Zebras //which zebra has right ssn? pull current data from persistant
                                               //.Include(z => z.SSN)
                                .Where(z => z.SSN == userId)
                                .ToList();



            if (list.Count() == 0)
            {
                return(Redirect("/User/Add"));
            }

            user = list[0];

            RouletteViewModel viewModel = new RouletteViewModel
            {
                UserId         = userId,
                Bets           = bets,
                BetAmount      = 50,
                Player         = list[0],
                LastSpinNumber = LastSpin,
                ZebraId        = list[0].Id
            };

            return(View(viewModel));
        }
コード例 #13
0
        public IActionResult Edit(Zebra editedZebra)
        {
            context.Zebras.Find(editedZebra.Id).Username = editedZebra.Username;
            context.Zebras.Find(editedZebra.Id).Bank     = editedZebra.Bank;
            context.SaveChanges();

            return(Redirect("/User"));
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: Slupov/Softuni-Homeworks
        private static void FeedAnimals()
        {
            var input = string.Empty;

            while ((input = Console.ReadLine()) != "End")
            {
                var animalInformation = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var foodInformation   = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Animal.Animal currentAnimal = null;
                Food.Food     currentFood   = null;

                var animalType   = animalInformation[0];
                var animalName   = animalInformation[1];
                var animalWeight = double.Parse(animalInformation[2]);
                var animalRegion = animalInformation[3];
                var animalBreed  = string.Empty;
                if (animalType == "Cat")
                {
                    animalBreed   = animalInformation[4];
                    currentAnimal = new Cat(animalName, animalType, animalWeight, animalRegion, animalBreed);
                }
                else
                {
                    switch (animalType)
                    {
                    case "Tiger":
                        currentAnimal = new Tiger(animalName, animalType, animalWeight, animalRegion);
                        break;

                    case "Zebra":
                        currentAnimal = new Zebra(animalName, animalType, animalWeight, animalRegion);
                        break;

                    case "Mouse":
                        currentAnimal = new Mouse(animalName, animalType, animalWeight, animalRegion);
                        break;
                    }
                }

                var foodType   = foodInformation[0];
                var foodAmount = int.Parse(foodInformation[1]);

                if (foodType == "Vegetable")
                {
                    currentFood = new Vegetable(foodAmount);
                }
                else if (foodType == "Meat")
                {
                    currentFood = new Meat(foodAmount);
                }

                currentAnimal.makeSound();
                currentAnimal.eatFood(currentFood);

                Console.WriteLine(currentAnimal);
            }
        }
コード例 #15
0
    public static void Main()
    {
        string animalInfo;

        while ((animalInfo = Console.ReadLine()) != "End")
        {
            var foodInfo     = Console.ReadLine().Split(' ');
            var animalTokens = animalInfo.Split(' ');

            var  foodType     = foodInfo[0];
            var  foodQuantity = int.Parse(foodInfo[1]);
            Food food         = null;

            if (foodType == "Vegetable")
            {
                food = new Vegetable(foodQuantity);
            }
            else
            {
                food = new Meat(foodQuantity);
            }

            var animalType         = animalTokens[0];
            var animalName         = animalTokens[1];
            var animalWeight       = double.Parse(animalTokens[2]);
            var animalLivingReagon = animalTokens[3];


            Animal animal = null;

            if (animalTokens.Length == 5)
            {
                var catBreed = animalTokens[4];
                animal = new Cat(animalName, animalType, animalWeight, animalLivingReagon, catBreed);
            }
            switch (animalType)
            {
            case "Tiger":
                animal = new Tiger(animalName, animalType, animalWeight, animalLivingReagon);
                break;

            case "Zebra":
                animal = new Zebra(animalName, animalType, animalWeight, animalLivingReagon);
                break;

            case "Mouse":
                animal = new Mouse(animalName, animalType, animalWeight, animalLivingReagon);
                break;
            }

            animal.MakeSound();
            animal.EatFood(food);
            Console.WriteLine(animal);
        }
    }
コード例 #16
0
ファイル: Program.cs プロジェクト: yordank/TheSoftUniJourney
        static void Main(string[] args)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            var input = Console.ReadLine();

            while (input != "End")
            {
                var    animalItems = input.Split();
                Animal animal      = null;
                switch (animalItems[0])
                {
                case "Cat":
                    animal = new Cat(animalItems[1], double.Parse(animalItems[2]), animalItems[4], animalItems[3]);
                    break;

                case "Zebra":
                    animal = new Zebra(animalItems[1], double.Parse(animalItems[2]), animalItems[3]);
                    break;

                case "Tiger":
                    animal = new Tiger(animalItems[1], double.Parse(animalItems[2]), animalItems[3]);
                    break;

                case "Mouse":
                    animal = new Mouse(animalItems[1], double.Parse(animalItems[2]), animalItems[3]);
                    break;
                }

                animal.makeSound();

                var foodItems = Console.ReadLine().Split();

                Food food = null;

                if (foodItems[0] == "Vegetable")
                {
                    food = new Vegetable(int.Parse(foodItems[1]));
                }

                if (foodItems[0] == "Meat")
                {
                    food = new  Meat(int.Parse(foodItems[1]));
                }


                animal.eat(food);

                Console.WriteLine(animal.ToString());

                input = Console.ReadLine();
            }
        }
コード例 #17
0
        public void MakeSound_NewZebra_ReturnsZebraSound()
        {
            //arrange
            const string expected = "zzz";
            var          test     = new Zebra("Bob", "zebra", 82, "Africa");
            //act
            var actual = test.MakeSound();

            //assert
            Assert.Equal(expected, actual);
        }
コード例 #18
0
    static void Main(string[] args)
    {
        string input = Console.ReadLine();

        while (input != "End")
        {
            string[] animalInfo = input.Split();
            string[] foodInfo   = Console.ReadLine().Split();

            string foodType     = foodInfo[0];
            int    foodQuantity = int.Parse(foodInfo[1]);

            string animalType   = animalInfo[0];
            string animalName   = animalInfo[1];
            double animalWeight = double.Parse(animalInfo[2]);
            string animalRegion = animalInfo[3];
            Animal animal       = new Mouse(" ", " ", 3.4, 3, " ");
            if (animalInfo.Length == 5)
            {
                string catBreed = animalInfo[4];
                animal = new Cat(animalName, animalType, animalWeight, foodQuantity, animalRegion, catBreed);
            }
            else
            {
                switch (animalType.ToLower())
                {
                case "tiger":
                    animal = new Tiger(animalName, animalType, animalWeight, foodQuantity, animalRegion);
                    break;

                case "zebra":
                    animal = new Zebra(animalName, animalType, animalWeight, foodQuantity, animalRegion);
                    break;

                case "mouse":
                    animal = new Mouse(animalName, animalType, animalWeight, foodQuantity, animalRegion);
                    break;
                }
            }
            Food food = new Meat(2);
            switch (foodType.ToLower())
            {
            case "meat": food = new Meat(foodQuantity); break;

            case "vegetable": food = new Vegetable(foodQuantity); break;
            }
            animal.MakeSound();
            animal.Eat(food);
            Console.WriteLine(animal);

            input = Console.ReadLine();
        }
    }
コード例 #19
0
    public static void Main()
    {
        string animalInfo = Console.ReadLine();

        while (animalInfo != "End")
        {
            string[] animalArgs = animalInfo.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            Mammal   animal;

            if (animalArgs[0] == "Mouse")
            {
                animal = new Mouse(animalArgs[1], double.Parse(animalArgs[2]), animalArgs[3]);
            }
            else if (animalArgs[0] == "Zebra")
            {
                animal = new Zebra(animalArgs[1], double.Parse(animalArgs[2]), animalArgs[3]);
            }
            else if (animalArgs[0] == "Cat")
            {
                animal = new Cat(animalArgs[1], double.Parse(animalArgs[2]), animalArgs[3], animalArgs[4]);
            }
            else
            {
                animal = new Tiger(animalArgs[1], double.Parse(animalArgs[2]), animalArgs[3]);
            }

            string[] foodArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            Food     food;

            if (foodArgs[0] == "Vegetable")
            {
                food = new Vegetable(int.Parse(foodArgs[1]));
            }
            else
            {
                food = new Meat(int.Parse(foodArgs[1]));
            }

            try
            {
                animal.MakeSound();
                animal.Eat(food);
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }

            Console.WriteLine(animal);

            animalInfo = Console.ReadLine();
        }
    }
コード例 #20
0
        public void Lion_ExistsOnAfricaContinent_AndEatAZebra()
        {
            // Arrange
            var lion  = new Lion();
            var zebra = new Zebra();

            // Act
            var result = lion.Eat(zebra);

            // Assert
            Assert.True(result);
        }
コード例 #21
0
    public static void Main()
    {
        string inputLine;

        while ((inputLine = Console.ReadLine()) != "End")
        {
            var animalTokens = inputLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            Animal currAnimal = null;

            var name   = animalTokens[1];
            var type   = animalTokens[0];
            var weight = double.Parse(animalTokens[2]);
            var home   = animalTokens[3];

            switch (animalTokens[0])
            {
            case "Cat":
                currAnimal = new Cat(name, type, weight, home, animalTokens[4]);
                break;

            case "Tiger":
                currAnimal = new Tiger(name, type, weight, home);
                break;

            case "Zebra":
                currAnimal = new Zebra(name, type, weight, home);
                break;

            case "Mouse":
                currAnimal = new Mouse(name, type, weight, home);
                break;
            }


            var foodTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            Food food = null;

            if (foodTokens[0] == "Vegetable")
            {
                food = new Vegetable(int.Parse(foodTokens[1]));
            }
            else
            {
                food = new Meat(int.Parse(foodTokens[1]));
            }
            currAnimal.MakeSound();
            currAnimal.EatFood(food);
            Console.WriteLine(currAnimal);
        }
    }
コード例 #22
0
    public static void Main()
    {
        var input = Console.ReadLine();

        while (input != "End")
        {
            var tokens     = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var foodTokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var  quantity = int.Parse(foodTokens[1]);
            Food food;

            if (foodTokens[0] == "Vegetable")
            {
                food = new Vegetable(quantity);
            }
            else
            {
                food = new Meat(quantity);
            }

            var name   = tokens[1];
            var weight = double.Parse(tokens[2]);
            var region = tokens[3];


            switch (tokens[0])
            {
            case "Mouse":
                var mouse = new Mouse(name, weight, region);
                ProcessEating(mouse, food);
                break;

            case "Zebra":
                var zebra = new Zebra(name, weight, region);
                ProcessEating(zebra, food);
                break;

            case "Tiger":
                var tiger = new Tiger(name, weight, region);
                ProcessEating(tiger, food);
                break;

            default:
                var cat = new Cat(name, weight, region, tokens[4]);
                ProcessEating(cat, food);
                break;
            }

            input = Console.ReadLine();
        }
    }
コード例 #23
0
        public static void ThirdDemo()
        {
            var        living = new Cat();
            IPresenter tiger  = new Tiger();
            IPresenter zebra  = new Zebra();

            tiger.Introduce(8, "Djini");

            living.presenter = tiger;
            living.presenter.Introduce(22, "Qnko");

            living.presenter = zebra;
            living.presenter.Introduce(15, "Nina");
        }
コード例 #24
0
    static void Main(string[] args)
    {
        var input = Console.ReadLine();

        while (input != "End")
        {
            var animalInfo = input
                             .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                             .ToList();

            var foodInfo = Console.ReadLine()
                           .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                           .ToList();

            Food food;
            if (foodInfo[0] == "Meat")
            {
                food = new Meat(int.Parse(foodInfo[1]));
            }
            else
            {
                food = new Vegetable(int.Parse(foodInfo[1]));
            }

            Animal animal;

            if (animalInfo[0] == "Mouse")
            {
                animal = new Mouse(animalInfo[1], animalInfo[0], double.Parse(animalInfo[2]), animalInfo[3]);
            }
            else if (animalInfo[0] == "Zebra")
            {
                animal = new Zebra(animalInfo[1], animalInfo[0], double.Parse(animalInfo[2]), animalInfo[3]);
            }
            else if (animalInfo[0] == "Cat")
            {
                animal = new Cat(animalInfo[1], animalInfo[0], double.Parse(animalInfo[2]), animalInfo[3], animalInfo[4]);
            }
            else
            {
                animal = new Tiger(animalInfo[1], animalInfo[0], double.Parse(animalInfo[2]), animalInfo[3]);
            }

            animal.MakeSound();
            animal.Eat(food);
            Console.WriteLine(animal);

            input = Console.ReadLine();
        }
    }
コード例 #25
0
        public void ShowAnimalInfo_NewZebraEats_ReturnsAnimalInfo()
        {
            //arrange
            const string expected = "zebra [Bob, 82, Africa, 5]";
            var          test     = new Zebra("Bob", "zebra", 82, "Africa");
            var          testFood = new Vegetable("vegetables", 5);

            test.Eat(testFood);
            //act
            var actual = test.ShowAnimalInfo();

            //assert
            Assert.Equal(expected, actual);
        }
コード例 #26
0
        // GET: PetAnimals
        public ActionResult Index()
        {
            Lion     lion     = new Lion("Lion Name", 6, "Male");
            Tiger    tiger    = new Tiger("Tiger Name", 4, "Female");
            Elephant elephant = new Elephant("Elephant Name", 9, "Female");
            Zebra    zebra    = new Zebra("Zebra Name", 8, "Male");
            Monkey   monkey   = new Monkey("Monkey", 45, "Male");

            List <AnimalsViewModel> obj = new List <AnimalsViewModel>();

            obj.Add(new AnimalsViewModel(zebra.Name, zebra.Count, zebra.GenderType));
            obj.Add(new AnimalsViewModel(monkey.Name, monkey.Count, monkey.GenderType));
            obj.Add(new AnimalsViewModel(lion.Name, lion.Count, lion.GenderType));
            obj.Add(new AnimalsViewModel(tiger.Name, tiger.Count, tiger.GenderType));
            obj.Add(new AnimalsViewModel(elephant.Name, elephant.Count, elephant.GenderType));
            return(View(obj));
        }
コード例 #27
0
    static void Main(string[] args)
    {
        var lion     = new Lion();
        var lionCage = new Cage <Lion>();

        lionCage.Animals = new List <Lion>();
        lionCage.Animals.Add(lion);
        var zebra     = new Zebra();
        var zebraCage = new Cage <Zebra>();

        zebraCage.Animals = new List <Zebra>();
        zebraCage.Animals.Add(zebra);
        var zoo = new Zoo();

        zoo.ZooCages = new List <ICage>();
        zoo.ZooCages.Add(lionCage);
    }
コード例 #28
0
        public static void Ukrywanie() // Nazewnictwo: maskowanie/ukrycie metody. Chodzi o to samo.
        {
            /* Klasy Kon i Ssak posiadają metody o takiej samej sygnaturze - public void PobierzImie().
             * Kon ukrywa metode Ssak.PobierzImie() i tworzy własną - public new void PobierzImie().
             * Gdy jakaś klasa dziedziczyć bedzie po klasie 'Kon' to odziedziczy tą metodę po klasie 'Kon' a nie 'Ssak'. Ponieważ ta metoda została ukryta.
             */

            Kon   kon     = new Kon("Konik");
            Ssak  ssakKon = new Kon("Konik Roman");
            Zebra zebra   = new Zebra("Zebra Irena");

            kon.PobierzImie();     // Wynik na konsoli 'Lubie biegac!'
            ssakKon.PobierzImie(); //Wynik na konsoli 'Konik Roman'
            zebra.PobierzImie();   // Wynik na konsoli 'Lubie biegac!'

            // Note: Na sygnaturę metody składa się: nazwa metody oraz ilość i typ parametrów. Typ zwracanej wartośćci nie ma znaczenia.
        }
コード例 #29
0
    private static void Main(string[] args)
    {
        var lion     = new Lion();
        var zebra    = new Zebra();
        var lionCage = new Cage <Lion>();

        lionCage.CageAnimal(lion);

        var zebraCage = new Cage <Zebra>();

        zebraCage.CageAnimal(zebra);

        var zoo = new Zoo();

        zoo.Cages.Add(lionCage);
        zoo.Cages.Add(zebraCage);
    }
コード例 #30
0
    public static IAnimal Load(String type)
    {
        IAnimal animal = null;

        switch (type)
        {
        case "Zebra":
            animal = new Zebra();
            break;

        case "Elephant":
            animal = new Elephant();
            break;

        default:
            throw new Exception();
        }
        return(animal);
    }
コード例 #31
0
ファイル: Croc.cs プロジェクト: jacob-carrier/ZanyZebras
 public override void gameEvent(Zebra z)
 {
     z.Health -= damage;
 }
コード例 #32
0
ファイル: Nuke.cs プロジェクト: jacob-carrier/ZanyZebras
 public override void gameEvent(Zebra z)
 {
     z.Health -= 20;
 }
コード例 #33
0
ファイル: IAbility.cs プロジェクト: jacob-carrier/ZanyZebras
 public virtual void gameEvent(Zebra z)
 {
 }
コード例 #34
0
ファイル: HDIC.cs プロジェクト: changchengxu/soc_nds_csharp
        /// <summary>
        /// 斑马打印机
        /// </summary>
        /// <param name="content1"></param>
        /// <param name="content2"></param>
        /// <param name="content3"></param>
        public static void ZebraPrinter(string content1,string content2,string content3)
        {
            #region 1
            ////实例化LPT端口操作类
            //Zebra Mylpt = new Zebra();
            //Mylpt.Open();
            //try
            //{

            //    //这里使用的是EAN-13码(^BE=EAN-13码)
            //    //N=不旋转,空的=条码高度(默认由BY来设置),Y=打印注释行,Y=打印校验位
            //    //^BY=条码字段默认参数设置2=窄条的宽度【点阵】,2.0=宽条与窄条的比例(默认=3.0有效范围——2.0到3.0【增量0.1】),95=条码的高度
            //    //^FD+"字符串"+^FS  打印内容
            //    //^A0B(A零B)表示字体的设置,数字为字符的高度和宽度
            //    Mylpt.Write("^XA~TA000~JSN^LT0^MMT^MNW^MTT^PON^PMN^LH0,0^JMA^PR4,4^MD30^JUS^LRN^CI0^XZ^XA^LL1199^FT572,415^A0B,48,72^FH\\^FD" +
            //        this.textBox6.Text.Trim() + "kg" + "^FS^FT578,920^A0B,48,57^FH\\^FD" +
            //        this.textBox5.Text.Trim() + "^FS^FT462,520^A0B,41,72^FH\\^FD" +
            //        this.textBox4.Text.Trim() + "%" + "^FS^FT465,775^A0B,46,72^FH\\^FD" +
            //        this.textBox3.Text.Trim() + "%" + "^FS^FT360,840^A0B,50,81^FH\\^FD" +
            //        this.textBox2.Text.Trim() + "^FS^FT254,920^A0B,75,124^FD" +
            //        this.textBox1.Text.Trim() + "^FS^BY3,2.1,95^FT339,165^BEN,,Y,Y^FD6948351700016^FS^PQ1,0,1,Y^XZ");
            //    Mylpt.Close();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("打开LPT端口时发生错误,原因" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            #endregion
               //^PQ(打印数量)指令有几个打印操作。它控制打印标签数量,打印机暂停打印标签数量,每个序列号复制数量。
            //^PQ50,10,1,Y:打印总数50张标签每个序列号只打一张。打印每组数量是10,但在每组间不暂停。
            #region 2
            //实例化LPT端口操作类
            Zebra Mylpt = new Zebra();
            Mylpt.Open();
            try
            {

                //这里使用的是EAN-13码(^BE=EAN-13码)
                //N=不旋转,空的=条码高度(默认由BY来设置),Y=打印注释行,Y=打印校验位
                //^BY=条码字段默认参数设置2=窄条的宽度【点阵】,2.0=宽条与窄条的比例(默认=3.0有效范围——2.0到3.0【增量0.1】),95=条码的高度
                //^FD+"字符串"+^FS  打印内容
                //^A0B(A零B)表示字体的设置,数字为字符的高度和宽度
                Mylpt.Write("^XA~TA000~JSN^LT0^MMT^MNW^MTT^PON^PMN^LH0,0^JMA^PR4,4^MD30^JUS^LRN^CI0^XZ^XA^LL1199^FT572,415^A0B,48,72^FH\\^FD" +
                   "STB ID"+content1+ "^FS^FT578,920^A0B,48,57^FH\\^FD" +
                   "CA ID"+content2+ "^FS^FT462,520^A0B,41,72^FH\\^FD" +
                   "SC ID"+content3 + "%" + "^FS^FT465,775^A0B,46,72^FH\\^FS^BY3,2.1,95^FT339,165^BEN,,Y,Y^FD6948351700016^FS^PQ1,0,1,Y^XZ");
                Mylpt.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打开LPT端口时发生错误,原因" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            #endregion

               //^XA 条码打印指令开始
               //^MD30 设置色带颜色的深度,取值范围从-30到30
               //^LH60,10设置条码纸的边距
               //^FO20,10 设置条码左上角的位置
               //^ACN,18,10 设置字体
               //^BY1.4,3,50 设置条码样式。1.4是条码的缩放级别,3是条码中粗细柱的比例,50是条码高度
               //^BCN,,Y,N 打印code128的指令
               //^FD123^FS 设置要打印的内容 ^FD是要打印的条码内容 ^FS表示换行
               //^AON  字体方向
               //^XZ 条码打印指令结束
               //^MCY 清除以前的标签
               //^LRN 不反向打印(N表示不反向)
               //^FWN 字体方向为正常(N表示正常)
               //^CFD 采用的字符字体
               //^PR 打印速度
               //^MNY 纸类型类Y表示非连续纸
               //^MTT纸种类T表示热传印纸
               //^MMT 打印模式T表示撕下
               //^MD 标签深度(值在-30到30之间)
        }
コード例 #35
0
 public void addEntity(Zebra z)
 {
     entities.Add(z);
 }