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