Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main ( string [] args )
- {
- House mylonelyhouse = new House ( ConsoleColor.Red, "Dnishche", 10 );
- mylonelyhouse.ShowAdress ();
- }
- }
- class House
- {
- ConsoleColor HouseColor;
- string Adress;
- int MaxTenants;
- private Tenant [] Tenants;
- public House ( ConsoleColor col, string adr, int max )
- {
- HouseColor = col;
- Adress = adr;
- MaxTenants = max;
- Tenants = new Tenant [max];
- }
- public void ShowAdress ( )
- {
- ConsoleColor defaultColor = Console.ForegroundColor;
- Console.ForegroundColor = HouseColor;
- Console.WriteLine (Adress);
- Console.ForegroundColor = defaultColor;
- }
- public Tenant [] FillHouse ( params Tenant [] tenant)
- {
- Tenant [] tens = Tenants;
- int tensCount = 0;
- bool IsFull = false;
- while ( !IsFull )
- {
- tens [tensCount] = tenant[tensCount];
- tensCount++;
- if ( tensCount == tens.Length-1 )
- {
- IsFull = true;
- Console.WriteLine ("Этот дом уже заполнен");
- }
- }
- return tens;
- }
- }
- class Tenant
- {
- string Name;
- byte Age;
- public Tenant (string name, byte age)
- {
- Name = name;
- Age = age;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment