﻿using System;

namespace Lab5
{
    public class Address
	{
		public string PostalCode
		{
			get;
			set;
		}
		public string Country
		{
			get;
			set;
		}
		public string City
		{
			get;
			set;
		}
		public string Street
		{
			get;
			set;
		}
		public string Building
		{
			get;
			set;
		}

		public Address()
		{
			this.PostalCode = this.Country = this.City = this.Street = this.Building = "";
        }

        public Address(string code, string country, string city, string street, string building)
        {
            this.PostalCode = code;
            this.Country    = country;
            this.City       = city;
            this.Street     = street;
            this.Building   = building;
        }

        public Address(Address copy)
		{
            if (copy != null)
            {
			    this.PostalCode = copy.PostalCode;
			    this.Country    = copy.Country;
			    this.City       = copy.City;
			    this.Street     = copy.Street;
			    this.Building   = copy.Building;
            }
            else
            {
                throw new ArgumentNullException("copy", "Copy object is NULL!");
            }
        }

        public override string ToString()
        {
            return $"{this.Country}, {this.PostalCode}, {this.City}, {this.Street} {this.Building}";
        }

        public static bool IsNullOrEmpty(Address value)
        {
            if (value == null)
            {
                return true;
            }

            if (string.IsNullOrEmpty(value.Country) ||
                string.IsNullOrEmpty(value.PostalCode) ||
                string.IsNullOrEmpty(value.City) ||
                string.IsNullOrEmpty(value.Street) ||
                string.IsNullOrEmpty(value.Building))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
