kisame1313

Untitled

Jul 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 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 ( params Tenant []  tenant)
  37.     {
  38.         Tenant [] tens = Tenants;
  39.         int tensCount = 0;
  40.         bool IsFull = false;
  41.         while ( !IsFull )
  42.         {
  43.             tens [tensCount] = tenant[tensCount];
  44.             tensCount++;
  45.  
  46.             if ( tensCount == tens.Length-1 )
  47.             {
  48.                 IsFull = true;
  49.                 Console.WriteLine ("Этот дом уже заполнен");
  50.             }
  51.         }
  52.  
  53.         return tens;
  54.            
  55.         }
  56. }
  57.  
  58. class Tenant
  59. {
  60.     string Name;
  61.     byte Age;
  62.  
  63.     public Tenant (string name, byte age)
  64.     {
  65.         Name = name;
  66.         Age = age;
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment