kisame1313

Untitled

Jul 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main ( string [] args )
  6.     {
  7.         House mylonelyhouse = new House ( ConsoleColor.Red, "Dnishche", 10 );
  8.         mylonelyhouse.ShowAdress ();
  9.     }
  10. }
  11.  
  12. class House
  13. {
  14.     ConsoleColor HouseColor;
  15.     string Adress;
  16.     int MaxTenants;
  17.     private Tenant [] Tenants;
  18.  
  19.     public House ( ConsoleColor col, string adr, int max )
  20.     {
  21.         HouseColor = col;
  22.         Adress = adr;
  23.         MaxTenants = max;
  24.         Tenants = new Tenant [max];
  25.  
  26.     }
  27.  
  28.     public void ShowAdress ( )
  29.     {
  30.         ConsoleColor defaultColor = Console.ForegroundColor;
  31.         Console.ForegroundColor = HouseColor;
  32.         Console.WriteLine (Adress);
  33.         Console.ForegroundColor = defaultColor;
  34.     }
  35.  
  36.     public Tenant [] FillHouse ()
  37.     {
  38.         Tenant [] tens = Tenants;
  39.         Tenant guy;
  40.         int tensCount = 0;
  41.         bool IsFull = false;
  42.         while ( !IsFull )
  43.         {
  44.             guy = new Tenant ( Console.ReadLine (), Convert.ToByte ( Console.ReadLine () ) );
  45.             tens [tensCount] = guy;
  46.             tensCount++;
  47.  
  48.             if ( tensCount == tens.Length-1 )
  49.             {
  50.                 IsFull = true;
  51.                 Console.WriteLine ("Этот дом уже заполнен");
  52.             }
  53.         }
  54.  
  55.         return tens;
  56.            
  57.         }
  58. }
  59.  
  60. class Tenant
  61. {
  62.     string Name;
  63.     byte Age;
  64.  
  65.     public Tenant (string name, byte age)
  66.     {
  67.         Name = name;
  68.         Age = age;
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment