# -*- coding: utf-8 -*-


class Inputs(object):


    def __init__(self):

        self.strings = {
            'wrong-number' : 'That\'s not an number. Try again.',
            'wrong-yn'     : 'Please, respond with yes (y) or not (n). Try again.'
        }


    def get(self, prompt_message, type_obj=str, default=None):

        while(True):

            content = input(prompt_message).strip()

            if(content == ''):
                content = default

            if(type_obj is int):

                if(
                    (not str(content).isnumeric()) or
                    (int(content) < 0)
                ):
                    print(self.strings['wrong-number'])
                    continue

                return int(content)
                
            elif(type_obj == bool):

                if(
                    (str(content).lower() == 'y') or
                    (content is True)
                ):
                    return True

                elif(
                    (str(content).lower() == 'n') or
                    (content is False)
                ):
                    return False

                else:
                    print(self.strings['wrong-yn'])
                    continue

            else:
                return content