Untitled

 avatar
unknown
plain_text
a year ago
4.1 kB
2
Indexable
namespace ConsoleApp1 
{ 
 class Man 
 { 
 public string name; 
 public string soname; 
 public int gender;// 0 - мужчина 1 - женщина 
 public string Sgender; 
 public string job; 
 /// 
 public DateTime now = DateTime.Now; //сегодняшняя дата 
 public DateTime born_date; 
 public int Age() 
 { 
 return (int)((now.Year * 365 + now.Month * 30 + now.Day) - (born_date.Year * 365 + born_date.Month * 30 + born_date.Day)) / 365; //определяем возраст 
 } 
 /// 
 public void print() 
 { 
 if (gender==0) Sgender = "Мужской"; else Sgender = "Женский"; 
 Console.WriteLine($"\nВАШ ПЕРСОНАЖ: {name} {soname}\n"); 
 Console.WriteLine($"Возраст: {Age()}"); 
 Console.WriteLine($"Пол = {Sgender}"); 
 Console.WriteLine($"Профессия = {job}"); 
 } 
 } 
 class Nobil : Man 
 { 
 public int income; 
 public int[] company = new int[10]; 
 } 
 class Owner : Man 
 { 
 public int[] location = new int[10]; 
 public int army; 
 } 
 internal class Program 
 { 
 static void Main(string[] args) 
 { 
 
 char choice; 
 do 
 { 
 Console.Write("Введите вашу роль: человек(t) знать(r) князь(f): "); 
 choice = char.Parse(Console.ReadLine()); 
 } 
 while (choice != 't' && choice != 'r' && choice != 'f'); 
 switch (choice) 
 { 
 case 't': 
 Man user = new Man(); 
 Console.Write("Введите вашу дату рождения: "); 
 user.born_date = DateTime.Parse(Console.ReadLine()); 
 Console.WriteLine("Введите имя и фамилию: "); 
 user.name = Console.ReadLine(); 
 user.soname = Console.ReadLine(); 
 Console.Write("Выберите пол: мужской(0) женский (1): "); 
 user.gender = int.Parse(Console.ReadLine()); 
 Console.Write("Введите название вашей профессии: "); 
 user.job = Console.ReadLine(); 
 user.print(); 
 break; 
 case 'r': 
 Nobil nobil = new Nobil(); 
 Console.Write("Введите вашу дату рождения: "); 
 nobil.born_date = DateTime.Parse(Console.ReadLine()); 
 Console.WriteLine("Введите имя и фамилию: "); 
 nobil.name = Console.ReadLine(); 
 nobil.soname = Console.ReadLine(); 
 Console.Write("Выберите пол: мужской(0) женский (1): "); 
 nobil.gender = int.Parse(Console.ReadLine()); 
 Console.Write("Введите название вашей профессии: "); 
 nobil.job = Console.ReadLine(); 
 Console.Write("Введите ваш доход(в рублях): "); 
 nobil.income = int.Parse(Console.ReadLine()); 
 Console.WriteLine("Перечислите ваши компании(до 10)"); 
 Console.WriteLine("0 - завершить перечисление"); 
 for (int i = 0; i < 10; i++) 
 { 
 nobil.company[i] = int.Parse(Console.ReadLine()); 
 if (nobil.company[i] == 0) break; 
 } 
 nobil.print(); 
 Console.WriteLine($"Доход = {nobil.income}"); 
 Console.WriteLine("ВАШИ КОМПАНИИ: "); 
 for(int j = 0; nobil.company[j]!=0; j++) 
 { 
 Console.Write($"{nobil.company[j]} "); 
 } 
 break; 
 case 'f': 
 Owner own = new Owner(); 
 Console.Write("Введите вашу дату рождения: "); 
 own.born_date = DateTime.Parse(Console.ReadLine()); 
 Console.WriteLine("Введите имя и фамилию: "); 
 own.name = Console.ReadLine(); 
 own.soname = Console.ReadLine(); 
 Console.Write("Выберите пол: мужской(0) женский (1): "); 
 own.gender = int.Parse(Console.ReadLine()); 
 Console.Write("Введите название вашей профессии: "); 
 own.job = Console.ReadLine(); 
 Console.WriteLine("Введите принадлежащие вам локации: "); 
 Console.WriteLine("0 - завершить перечисление"); 
 for (int h = 0; h < 10; h++) 
 { 
 own.location[h]=int.Parse(Console.ReadLine()); 
 if (own.location[h] == 0) break; 
 } 
 own.print(); 
 Console.WriteLine("ВАШИ ЛОКАЦИИ: "); 
 for (int c = 0; own.location[c]!=0; c++) 
 { 
 Console.Write($"{own.location[c]} "); 
 } 
 break; 
 } 
 Console.ReadKey(); 
 } 
 } 
}
Leave a Comment