static void Main(string[] args) { Farm farm = new Farm("Айыл Чарба", "г.Бишкек ул.Чуй №182"); Animal cow = new Cow("Уй", 2, "Ж", 740); Animal cow1 = new Cow("Бука", 2, "М", 760); Sheep sheep = new Sheep("Кой", 5, "Ж", 48); Sheep sheep1 = new Sheep("Кочкор", 3, "М", 60); Animal horse = new Horse("Ат", 7, "М", 650); Animal horse1 = new Horse("Бээ", 7, "Ж", 650); cow.Eat(); sheep.Eat(); horse.Eat(); while (true) { farm.FullInfo(); Console.Write("Для добавление животных в ферму выберите из списка " + "\ncow-->уй\tcow1-->бука\nsheep-->кой\tsheep1-->кочкор\nhorse-->ат\thorse1-->бээ\n>"); var input = Console.ReadLine().ToLower(); switch (input) { case "cow": farm.AddCow(cow); break; case "cow1": farm.AddCow(cow1); break; case "sheep": farm.AddSheep(sheep); break; case "sheep1": farm.AddSheep(sheep1); break; case "horse": farm.AddHorse(horse); break; case "horse1": farm.AddHorse(horse1); break; default: break; } } }
static void Main(string[] args) { //build a farm Cow betsy = new Cow(); Chicken little = new Chicken(); Goat billy = new Goat(); Sheep lambchop = new Sheep(); Console.WriteLine("Hello and welcome to my farm!"); Console.WriteLine("Let me introduce you to our animals"); Console.WriteLine(); //Call the animals lambchop.Talk(); little.Talk(); billy.Talk(); betsy.Talk(); //our custom animal newAnimal(); }
public Barn() { Animals = new Animal[4]; Animal an1 = new Cow("Flower"); Animal an2 = new Horse("Ben"); Animal an3 = new Pig("Martha"); Animal an4 = new Sheep("Meggie"); Farmers = new Farmer[3]; Farmer fa1 = new Farmer("John", 15); Farmer fa2 = new Farmer("Samanta", 4); Farmer fa3 = new Farmer("Nick", 7); Animals[0] = an1; Animals[1] = an2; Animals[2] = an3; Animals[3] = an4; Farmers[0] = fa1; Farmers[1] = fa2; Farmers[2] = fa3; }
static void Main(string[] args) { string userInput; Console.WriteLine ("Which animal would you like to meet?"); start: Console.WriteLine ("\r\n1. Pig\r\n2. Cow\r\n3. Horse\r\n4. Sheep\r\n5. Chicken"); int userSelect = int.Parse(userInput = Console.ReadLine()); if (userSelect >= 1 && userSelect <= 5) { switch (userSelect) { case 1: Animals animal1 = new Pig(); animalInfo(animal1); break; case 2: Animals animal2 = new Cow(); animalInfo(animal2); break; case 3: Animals animal3 = new Horse(); animalInfo(animal3); break; case 4: Animals animal4 = new Sheep(); animalInfo(animal4); break; case 5: Animals animal5 = new Chicken(); animalInfo(animal5); break; } } else { Console.WriteLine ("Please enter an integer between 1-5."); goto start; } string userInput1; Console.WriteLine ("Which crop would you like to explore?"); Console.WriteLine ("1. Corn\r\n2. Soybeans\r\n3. Wheat"); start1: int userSelect1 = int.Parse(userInput1 = Console.ReadLine()); if (userSelect1 >= 1 && userSelect1 <= 3) { switch (userSelect1) { case 1: Crops crop1 = new Corn(); cropInfo(crop1); break; case 2: Crops crop2 = new Soybean(); cropInfo(crop2); break; case 3: Crops crop3 = new Wheat(); cropInfo(crop3); break; } } else { Console.WriteLine ("Please enter an integer between 1-3."); goto start1; } string userInput2; Console.WriteLine ("Would you like to visit more of the farm?"); Console.WriteLine ("1. Yes\r\n2. No"); start2: int userSelect2 = int.Parse(userInput2 = Console.ReadLine()); if (userSelect2 >= 1 && userSelect2 <= 2) { switch (userSelect2) { case 1: goto start; case 2: return; } } else { Console.WriteLine ("Please enter an integer between 1-2."); goto start2; } void animalInfo(Animals input) { var animal = input; Console.WriteLine ("Your animal type is {0}\r\n" + "Your animal's name is {1}\r\n" + "Your animal's color is {2}\r\n" + "Your animal says \"{3}\"", animal.AnimalType, animal.AnimalName, animal.AnimalColor, animal.AnimalNoise); Console.ReadLine(); } void cropInfo(Crops input) { var crop = input; Console.WriteLine ("Your crop type is {0}\r\n" + "Your crop's purpose is {1}\r\n" + "Your crop's color is {2}\r\n", crop.CropType, crop.CropPurpose, crop.CropColor); Console.ReadLine(); } }