From 229f0def840c1486f7658bfe48c38092f340ddb7 Mon Sep 17 00:00:00 2001 From: RedTerror <37833085+RedTerrorDark@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:10:52 +0700 Subject: [PATCH 1/2] cool commit --- HELP ME.cs | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 HELP ME.cs diff --git a/HELP ME.cs b/HELP ME.cs new file mode 100644 index 0000000..6cb19ee --- /dev/null +++ b/HELP ME.cs @@ -0,0 +1,214 @@ +/// +///###################### +///# Некрасов # +///# Антон # +///# ПИ-251 # +///###################### +/// + +using System; +using System.Collections.Generic; + +public abstract class Animal { + public string Name { get; set; } + public int Age { get; set; } + public string Habitat { get; set; } + public string DietType { get; set; } + + public Animal(string name, int age, string habitat, string dietType) { + Name = name; + Age = age; + Habitat = habitat; + DietType = dietType; + } + + public virtual string GetInfo() { + return $"Name: {Name}, Age: {Age}, Habitat: {Habitat}, Diet: {DietType}"; + } +} + +public class Mammal : Animal { + public bool HasFur { get; set; } + + public Mammal(string name, int age, string habitat, string dietType, bool hasFur) + : base(name, age, habitat, dietType) { + HasFur = hasFur; + } + + public override string GetInfo() { + return base.GetInfo() + + $", Type: Mammal, Fur: {(HasFur ? "yes" : "no")}"; + } +} + +public class Bird : Animal { + public double WingSpan { get; set; } + + public Bird(string name, int age, string habitat, string dietType, double wingSpan) + : base(name, age, habitat, dietType) { + WingSpan = wingSpan; + } + + public override string GetInfo() { + return base.GetInfo() + + $", Type: Bird, Wing Span: {WingSpan} m"; + } +} + +public class Fish : Animal { + public string WaterType { get; set; } + + public Fish(string name, int age, string habitat, string dietType, string waterType) + : base(name, age, habitat, dietType) { + WaterType = waterType; + } + + public override string GetInfo() { + return base.GetInfo() + + $", Type: Fish, Water Type: {WaterType}"; + } +} + +public class Reptile : Animal { + public bool IsVenomous { get; set; } + + public Reptile(string name, int age, string habitat, string dietType, bool isVenomous) + : base(name, age, habitat, dietType) { + IsVenomous = isVenomous; + } + + public override string GetInfo() { + return base.GetInfo() + + $", Type: Reptile, Venomous: {(IsVenomous ? "yes" : "no")}"; + } +} + +public class Amphibian : Animal { + public string SkinMoisture { get; set; } + + public Amphibian(string name, int age, string habitat, string dietType, string skinMoisture) + : base(name, age, habitat, dietType) { + SkinMoisture = skinMoisture; + } + + public override string GetInfo() { + return base.GetInfo() + + $", Type: Amphibian, Skin Moisture: {SkinMoisture}"; + } +} + +public class AnimalManager { + private static AnimalManager _instance; + + public static AnimalManager Instance { + get { + if (_instance == null) + _instance = new AnimalManager(); + return _instance; + } + } + + private List animals = new List(); + + private AnimalManager() { } + + public void AddAnimal(Animal animal) { + animals.Add(animal); + } + + public void ShowAllAnimals() { + if (animals.Count == 0) { + Console.WriteLine("But, no one came."); + return; + } + + for (int index = 0; index < animals.Count; ++index) { + Console.WriteLine($"{index + 1}. {animals[index].GetInfo()}"); + } + } + + public void Menu() { + while (true) { + Console.WriteLine("\n1 - show me animals."); + Console.WriteLine("2 - add animal"); + Console.WriteLine("0 - nah. bye."); + + string choice = Console.ReadLine(); + + switch (choice) { + case "1": + ShowAllAnimals(); + break; + + case "2": + CreateAnimal(); + break; + + case "0": + return; + + default: + Console.WriteLine("no."); + break; + } + } + } + + private void CreateAnimal() { + Console.WriteLine("Type:"); + Console.WriteLine("1 - Mammal"); + Console.WriteLine("2 - Bird"); + Console.WriteLine("3 - Fish"); + Console.WriteLine("4 - Reptile"); + Console.WriteLine("5 - Amphibian"); + + string type = Console.ReadLine(); + + Console.Write("Name: "); + string name = Console.ReadLine(); + + Console.Write("Age: "); + int age = int.Parse(Console.ReadLine()); + + Console.Write("Habitat: "); + string habitat = Console.ReadLine(); + + Console.Write("Diet: "); + string diet = Console.ReadLine(); + + switch (type) { + case "1": + Console.Write("Has Fur? (true/false): "); + bool fur = bool.Parse(Console.ReadLine()); + AddAnimal(new Mammal(name, age, habitat, diet, fur)); + break; + + case "2": + Console.Write("Wing Span: "); + double wing = double.Parse(Console.ReadLine()); + AddAnimal(new Bird(name, age, habitat, diet, wing)); + break; + + case "3": + Console.Write("Water type: "); + string water = Console.ReadLine(); + AddAnimal(new Fish(name, age, habitat, diet, water)); + break; + + case "4": + Console.Write("Venomous? (true/false): "); + bool venom = bool.Parse(Console.ReadLine()); + AddAnimal(new Reptile(name, age, habitat, diet, venom)); + break; + + case "5": + Console.Write("Skin color: "); + string moisture = Console.ReadLine(); + AddAnimal(new Amphibian(name, age, habitat, diet, moisture)); + break; + + default: + Console.WriteLine("nah."); + break; + } + } \ No newline at end of file From 36077778a459393db0aa06c8d0afbc148f23c372 Mon Sep 17 00:00:00 2001 From: RedTerror <37833085+RedTerrorDark@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:02:47 +0700 Subject: [PATCH 2/2] fix --- HELP ME.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/HELP ME.cs b/HELP ME.cs index 6cb19ee..2b0d3ee 100644 --- a/HELP ME.cs +++ b/HELP ME.cs @@ -129,9 +129,7 @@ public void ShowAllAnimals() { public void Menu() { while (true) { - Console.WriteLine("\n1 - show me animals."); - Console.WriteLine("2 - add animal"); - Console.WriteLine("0 - nah. bye."); + Console.WriteLine("\n 1 - show me animals.\n 2 - add animal \n 0 - nah. bye."); string choice = Console.ReadLine(); @@ -155,12 +153,8 @@ public void Menu() { } private void CreateAnimal() { - Console.WriteLine("Type:"); - Console.WriteLine("1 - Mammal"); - Console.WriteLine("2 - Bird"); - Console.WriteLine("3 - Fish"); - Console.WriteLine("4 - Reptile"); - Console.WriteLine("5 - Amphibian"); + Console.WriteLine("\n Type:\n 1 - Mammal \n 2 - Bird \n 3 - Fish \n 4 - Reptile \n 5 - Amphibian"); + string type = Console.ReadLine(); @@ -211,4 +205,5 @@ private void CreateAnimal() { Console.WriteLine("nah."); break; } - } \ No newline at end of file + + }