"""
Module containing some postal helper functions

Author: Anne Bracy (awb93)
Date:   Feb 27, 2019
"""

def good_state(state):
    return type(state) == str and len(state) == 2 and state == "NY"
    


class Address():
    """
    An instance is an address with 5 fields
    
    to create an address, type:
    a1 = shapes.Address(100, "Main Street", "Ithaca", "NY", "14850")
    """

    def __init__(self, num, st, city, state, zip):
        """
        Creates a new Address with the given coordinates.

        INSTANCE ATTRIBUTES:
        num: an int
        st: str representing the street name
        city: str the city name
        state: a 2-digit all-caps str representing the state
        zip: a 5 digit string
        """
        assert type(num) == int, "street number must be an int"
        assert type(st) == str, "street name must be a str"
        assert type(city) == str, "city must be a str"
        assert good_state(state), "state is ill-formatted"
        assert type(zip) == str, "zip code must be a str"
        self.num = num
        self.st = st
        self.city = city
        self.state = state
        self.zip = zip

def print_mailing_label(addr):
    """
    prints out the address in standard mailing label format
    
    Precondition: addr is of type Address
    """
    print("Ship to:")
    print(str(addr.num) + " " + addr.st)
    print(addr.city+", "+addr.state+"  "+addr.zip)

def print_european_mailing_label(addr):
    """
    prints out the address in european address format
    
    Precondition: addr is of type Address
    """
    print("An:")
    print(addr.st+ " " +str(addr.num))
    print(addr.zip+" "+addr.city)
