Advertisement
Gillito

Untitled

Jul 21st, 2015
206
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.             name.WithMiddleName = true;
  17.             person.ShowInfo();
  18.  
  19.         }
  20.     }
  21.  
  22.     class NameInfo
  23.     {
  24.         public NameInfo(string fName, string mName, string lName)
  25.         {
  26.             FirstName = fName;
  27.             MiddleName = mName;
  28.             LastName = lName;
  29.         }
  30.  
  31.         public string FirstName
  32.         {
  33.             get;
  34.             set;
  35.         }
  36.         public string MiddleName
  37.         {
  38.             get;
  39.             set;
  40.         }
  41.         public string LastName
  42.         {
  43.             get;
  44.             set;
  45.         }
  46.         public bool WithMiddleName
  47.         {
  48.             get;
  49.             set;
  50.         }
  51.         public string FullName
  52.         {
  53.             get
  54.             {
  55.                 string tempname = FirstName + " " + MiddleName + " " + LastName;;
  56.                 if (WithMiddleName == false)
  57.                     tempname = FirstName + " " + LastName;
  58.                 return tempname;
  59.             }
  60.         }
  61.     }
  62.  
  63.     class AdressInfo
  64.     {
  65.         public AdressInfo(string city, string street, int house, int apartment)
  66.         {
  67.             City = city;
  68.             Street = street;
  69.             House = house;
  70.             Apartment = apartment;
  71.         }
  72.  
  73.         public string City
  74.         {
  75.             get;
  76.             set;
  77.         }
  78.         public string Street
  79.         {
  80.             get;
  81.             set;
  82.         }
  83.         public int House
  84.         {
  85.             get;
  86.             set;
  87.         }
  88.         public int Apartment
  89.         {
  90.             get;
  91.             set;
  92.         }
  93.     }
  94.  
  95.     class Person
  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(PersonName.FullName);
  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