Advertisement
Gillito

Untitled

Jul 21st, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 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.             Person person = new Person();
  14.             person.ShowInfo();
  15.         }
  16.     }
  17.  
  18.     class NameInfo
  19.     {
  20.         public NameInfo(string fName, string mName, string lName)
  21.         {
  22.             FirstName = fName;
  23.             MiddleName = mName;
  24.             LastName = lName;
  25.         }
  26.  
  27.         public string FirstName
  28.         {
  29.             get;
  30.             private set;
  31.         }
  32.         public string MiddleName
  33.         {
  34.             get;
  35.             private set;
  36.         }
  37.         public string LastName
  38.         {
  39.             get;
  40.             private set;
  41.         }
  42.         public bool WithMiddleName
  43.         {
  44.             get;
  45.             set;
  46.         }
  47.         public string FullName
  48.         {
  49.             get
  50.             {
  51.                 if (WithMiddleName == true)
  52.                     return FirstName + " " + MiddleName + " " + LastName;
  53.                 return
  54.                     FirstName + " " + LastName;
  55.             }
  56.         }
  57.     }
  58.  
  59.     class AdressInfo
  60.     {
  61.         public AdressInfo(string city, string street, int house, int apartment)
  62.         {
  63.             City = city;
  64.             Street = street;
  65.             House = house;
  66.             Apartment = apartment;
  67.         }
  68.  
  69.         public string City
  70.         {
  71.             get;
  72.             set;
  73.         }
  74.         public string Street
  75.         {
  76.             get;
  77.             set;
  78.         }
  79.         public int House
  80.         {
  81.             get;
  82.             set;
  83.         }
  84.         public int Apartment
  85.         {
  86.             get;
  87.             set;
  88.         }
  89.     }
  90.  
  91.     class Person
  92.     {
  93.         NameInfo name = new NameInfo("James", "Paul", "Abbot");
  94.  
  95.         AdressInfo adress = new AdressInfo("Chicago", "Monster Hunter Ave.", 14, 301);
  96.  
  97.         public void ShowInfo()
  98.         {
  99.             Console.WriteLine("{0} {1} {2}", name.FirstName, name.MiddleName, name.LastName);
  100.             Console.WriteLine("{0} {1} {2} {3}", adress.City, adress.Street, adress.House, adress.Apartment);
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement