Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication58
- {
- class Program
- {
- static void Main(string[] args)
- {
- NameInfo name = new NameInfo("James", "Paul", "Abbot");
- AdressInfo address = new AdressInfo("Chicago", "Monster Hunter Ave.", 14, 301);
- Person person = new Person(name, address);
- name.WithMiddleName = true;
- person.ShowInfo();
- }
- }
- class NameInfo
- {
- public NameInfo(string fName, string mName, string lName)
- {
- FirstName = fName;
- MiddleName = mName;
- LastName = lName;
- }
- public string FirstName
- {
- get;
- set;
- }
- public string MiddleName
- {
- get;
- set;
- }
- public string LastName
- {
- get;
- set;
- }
- public bool WithMiddleName
- {
- get;
- set;
- }
- public string FullName
- {
- get
- {
- string tempname = FirstName + " " + MiddleName + " " + LastName;;
- if (WithMiddleName == false)
- tempname = FirstName + " " + LastName;
- return tempname;
- }
- }
- }
- class AdressInfo
- {
- public AdressInfo(string city, string street, int house, int apartment)
- {
- City = city;
- Street = street;
- House = house;
- Apartment = apartment;
- }
- public string City
- {
- get;
- set;
- }
- public string Street
- {
- get;
- set;
- }
- public int House
- {
- get;
- set;
- }
- public int Apartment
- {
- get;
- set;
- }
- }
- class Person
- {
- public Person(NameInfo name, AdressInfo adress)
- {
- PersonName = name;
- PersonAddress = adress;
- }
- public NameInfo PersonName
- {
- get;
- set;
- }
- public AdressInfo PersonAddress
- {
- get;
- set;
- }
- public void ShowInfo()
- {
- Console.WriteLine(PersonName.FullName);
- Console.WriteLine("{0} {1} {2} {3}", PersonAddress.City, PersonAddress.Street, PersonAddress.House, PersonAddress.Apartment);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement