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)
- {
- string personname = "James", middlename = "Paul", lastname = "Abbot";
- string city = "Chicago", street = "Monster Hunter Ave.";
- int house = 14, apartment = 301;
- NameInfo name = new NameInfo(personname, middlename, lastname);
- AdressInfo address = new AdressInfo(city, street, house, apartment);
- Person person = new Person(name, address);
- name.WithMiddleName = true;
- person.ShowInfo();
- Console.WriteLine();
- Person person2 = new Person(personname, middlename, lastname, city, street, house, apartment);
- name.WithMiddleName = false;
- person2.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 NameInfo Name
- {
- get;
- set;
- }
- public AdressInfo Address
- {
- get;
- set;
- }
- public Person(string fName, string mName, string lName, string city, string street, int house, int apartment)
- {
- Name = new NameInfo(fName, mName, lName);
- Address = new AdressInfo(city, street, house, apartment);
- }
- public Person(NameInfo name, AdressInfo address)
- {
- Name = name;
- Address = address;
- }
- public void ShowInfo()
- {
- Console.WriteLine(Name.FullName);
- Console.WriteLine("{0} {1} {2} {3}", Address.City, Address.Street, Address.House, Address.Apartment);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement