b
This commit is contained in:
@@ -2,20 +2,20 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
enum _Type_Animal{
|
||||
public enum _Type_Animal{
|
||||
herbivorous, // травоядный
|
||||
predator, // хищник
|
||||
omnivorous, // всеядный
|
||||
insectivorous // насекомоядный
|
||||
}
|
||||
|
||||
enum _Habitat{
|
||||
public enum _Habitat{
|
||||
water_env, // водная среда
|
||||
earth_env, // наземная среда
|
||||
wind_env // воздушная среда
|
||||
}
|
||||
|
||||
enum _Continent{
|
||||
public enum _Continent{
|
||||
africa,
|
||||
north_am,
|
||||
south_am,
|
||||
@@ -28,71 +28,74 @@ class Animal{
|
||||
|
||||
//-constructors-----------------------------------
|
||||
public Animal(){
|
||||
Console.WriteLine("базовый конструктор");
|
||||
Console.WriteLine(">>базовый конструктор");
|
||||
_name = "пусто";
|
||||
_age = 0;
|
||||
_count_limbs = 0;
|
||||
}
|
||||
|
||||
public Animal(string _name_, int _age_, int _count_limbs_,
|
||||
_Type_Animal type_animal, _Habitat habitat,
|
||||
_Continent continent){
|
||||
_Type_Animal _type_animal_, _Habitat _habitat_,
|
||||
_Continent _continent_){
|
||||
|
||||
Console.WriteLine("конструктор с параметрами");
|
||||
Console.WriteLine(">>конструктор с параметрами");
|
||||
_name = _name_;
|
||||
_age = _age_;
|
||||
_count_limbs = _count_limbs_;
|
||||
|
||||
Type_animal = type_animal;
|
||||
Habitat = habitat;
|
||||
Continent = continent;
|
||||
type_animal = _type_animal_;
|
||||
habitat = _habitat_;
|
||||
continent = _continent_;
|
||||
}
|
||||
|
||||
//-override-operators-----------------------------
|
||||
public static bool operator ==(Animal animal_1, Animal animal_2){
|
||||
public static bool operator ==(Animal? animal_1, Animal? animal_2){
|
||||
return ReferenceEquals(animal_1, animal_2);
|
||||
}
|
||||
|
||||
public static bool operator !=(Animal animal_1, Animal animal_2){
|
||||
public static bool operator !=(Animal? animal_1, Animal? animal_2){
|
||||
return !(animal_1 == animal_2);
|
||||
}
|
||||
|
||||
//-methods----------------------------------------
|
||||
public void GetSound(){
|
||||
Console.WriteLine("издает звук!");
|
||||
Console.WriteLine(" >издает звук!");
|
||||
}
|
||||
|
||||
public void CanSwim(){
|
||||
if (Habitat == _Habitat.water_env){
|
||||
Console.WriteLine("животное умеет плавать!");
|
||||
if (habitat == _Habitat.water_env){
|
||||
Console.WriteLine(" >животное умеет плавать!");
|
||||
}
|
||||
else{
|
||||
Console.WriteLine("животное не умеет плавать!");
|
||||
Console.WriteLine(" >животное не умеет плавать!");
|
||||
}
|
||||
}
|
||||
|
||||
public void CanFly(){
|
||||
if (Habitat == _Habitat.wind_env){
|
||||
Console.WriteLine("животное умеет летать!");
|
||||
if (habitat == _Habitat.wind_env){
|
||||
Console.WriteLine(" >животное умеет летать!");
|
||||
}
|
||||
else{
|
||||
Console.WriteLine("животное не умеет летать!");
|
||||
Console.WriteLine(" >животное не умеет летать!");
|
||||
}
|
||||
}
|
||||
|
||||
public void ExistsTail(){
|
||||
if (Type_animal == _Type_Animal.insectivorous){
|
||||
Console.WriteLine("у животного нет хвоста!");
|
||||
if (type_animal == _Type_Animal.insectivorous){
|
||||
Console.WriteLine(" >у животного нет хвоста!");
|
||||
}
|
||||
else{
|
||||
Console.WriteLine("у животного есть хвост!");
|
||||
Console.WriteLine(" >у животного есть хвост!");
|
||||
}
|
||||
}
|
||||
|
||||
public void GetAllData(){
|
||||
Console.WriteLine("имя: " + Name);
|
||||
Console.WriteLine("возраст: " + Age);
|
||||
Console.WriteLine("количество конечностей: " + Count_Limbs);
|
||||
Console.WriteLine("тип животного: " + Type_animal);
|
||||
Console.WriteLine("среда обитания: " + Habitat);
|
||||
Console.WriteLine("континент: " + Continent);
|
||||
Console.WriteLine("имя: " + _name);
|
||||
Console.WriteLine("возраст: " + _age);
|
||||
Console.WriteLine("количество конечностей: " + _count_limbs);
|
||||
Console.WriteLine("тип животного: " + type_animal);
|
||||
Console.WriteLine("среда обитания: " + habitat);
|
||||
Console.WriteLine("континент: " + continent);
|
||||
}
|
||||
|
||||
//-public-fields----------------------------------
|
||||
@@ -118,7 +121,7 @@ class Animal{
|
||||
private string _name;
|
||||
private int _age;
|
||||
private int _count_limbs;
|
||||
private _Type_Animal Type_animal{ set; }
|
||||
private _Habitat Habitat{ set; }
|
||||
private _Continent Continent{ set; }
|
||||
private _Type_Animal type_animal;
|
||||
private _Habitat habitat;
|
||||
private _Continent continent;
|
||||
}
|
||||
Reference in New Issue
Block a user