# L-24 MCS 260 : class Person
"""
For each person we store the name, a PIN, and its status,
which is either librarian or patron of the library.
"""

class Person(object):
    """
    An object of the class Person is either
    a librarian or a patron of the library.
    """
    def __init__(self, **nps):
        """
        The arguments of the construct are name, PIN,
        and status, given in the dictionary nps.
        For each key not in nps, the user is prompted.
        """
        if 'name' in nps:
            self.name = nps['name']
        else:
            self.name = input('Give your name : ')
        if 'PIN' in nps:
            self.pin = nps['PIN']
        else:
            rawpin = input('Give your PIN : ')
            self.pin = int(rawpin)
        if 'status' in nps:
            self.librarian = nps['status']
        else:
            answer = input('Librarian ? (y/n) ')
            if answer == 'y':
                self.librarian = True
            else:
                self.librarian = False

    def __str__(self):
        "string representation of a person"
        prt = self.name + ' with PIN '
        prt += '%2d' % self.pin
        if self.librarian:
            prt += ' is a librarian'
        else:
            prt  += ' is a patron'
        return prt

    def check(self):
        "returns the status of the person"
        return self.librarian

    def change(self):
        "prompts for a new PIN and status"
        print('Hi ' + self.name)
        rawpin = input('Give new PIN : ')
        self.pin = int(rawpin)
        answer = input('Librarian ? (y/n) ')
        if answer == 'y':
            self.librarian = True
        else:
            self.librarian = False
