Advertisement
Gillito

Untitled

Jul 22nd, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.00 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.  
  96.         NameInfo name = new NameInfo("","","");
  97.         AdressInfo address = new AdressInfo("", "", 0, 0);
  98.  
  99.         public Person(string fName, string mName, string lName, string city, string street, int house, int apartment)
  100.         {
  101.             name.FirstName = fName;
  102.             name.MiddleName = mName;
  103.             name.LastName = lName;
  104.             address.City = city;
  105.             address.Street = street;
  106.             address.House = house;
  107.             address.Apartment = apartment;
  108.         }
  109.  
  110.         //public Person(NameInfo name, AdressInfo adress)
  111.         //{
  112.         //    PersonName = name;
  113.         //    PersonAddress = adress;
  114.         //}
  115.  
  116.         //public NameInfo PersonName
  117.         //{
  118.         //    get;
  119.         //    set;
  120.         //}
  121.  
  122.         //public AdressInfo PersonAddress
  123.         //{
  124.         //    get;
  125.         //    set;
  126.         //}
  127.  
  128.         public void ShowInfo()
  129.         {
  130.             Console.WriteLine(name.FullName);
  131.             Console.WriteLine("{0} {1} {2} {3}", address.City, address.Street, address.House, address.Apartment);
  132.         }
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement