Advertisement
Gillito

Untitled

Jul 21st, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication58
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             NameInfo name = new NameInfo("James", "Paul", "Abbot");
  14.             AdressInfo address = new AdressInfo("Chicago", "Monster Hunter Ave.", 14, 301);
  15.             Person person = new Person(name, address);
  16.             person.ShowInfo();
  17.  
  18.         }
  19.     }
  20.  
  21.     class NameInfo
  22.     {
  23.         public NameInfo(string fName, string mName, string lName)
  24.         {
  25.             FirstName = fName;
  26.             MiddleName = mName;
  27.             LastName = lName;
  28.         }
  29.  
  30.         public string FirstName
  31.         {
  32.             get;
  33.             set;
  34.         }
  35.         public string MiddleName
  36.         {
  37.             get;
  38.             set;
  39.         }
  40.         public string LastName
  41.         {
  42.             get;
  43.             set;
  44.         }
  45.         public bool WithMiddleName
  46.         {
  47.             get;
  48.             set;
  49.         }
  50.         public string FullName
  51.         {
  52.             get
  53.             {
  54.                 if (WithMiddleName == true)
  55.                     return FirstName + " " + MiddleName + " " + LastName;
  56.                 return
  57.                     FirstName + " " + LastName;
  58.             }
  59.         }
  60.     }
  61.  
  62.     class AdressInfo
  63.     {
  64.         public AdressInfo(string city, string street, int house, int apartment)
  65.         {
  66.             City = city;
  67.             Street = street;
  68.             House = house;
  69.             Apartment = apartment;
  70.         }
  71.  
  72.         public string City
  73.         {
  74.             get;
  75.             set;
  76.         }
  77.         public string Street
  78.         {
  79.             get;
  80.             set;
  81.         }
  82.         public int House
  83.         {
  84.             get;
  85.             set;
  86.         }
  87.         public int Apartment
  88.         {
  89.             get;
  90.             set;
  91.         }
  92.     }
  93.  
  94.     class Person
  95.     {
  96.        
  97.         public Person(NameInfo name, AdressInfo adress)
  98.         {
  99.             PersonName = name;
  100.             PersonAddress = adress;
  101.         }
  102.  
  103.         public NameInfo PersonName
  104.         {
  105.             get;
  106.             set;
  107.         }
  108.  
  109.         public AdressInfo PersonAddress
  110.         {
  111.             get;
  112.             set;
  113.         }
  114.  
  115.         public void ShowInfo()
  116.         {
  117.             Console.WriteLine("{0} {1} {2}", PersonName.FirstName, PersonName.MiddleName, PersonName.LastName);
  118.             Console.WriteLine("{0} {1} {2} {3}", PersonAddress.City, PersonAddress.Street, PersonAddress.House, PersonAddress.Apartment);
  119.         }
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement