Advertisement
Gillito

Untitled

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