import doctest


class SMS_store:

    def __init__(self):
        """Initialize an empty store
        
        >>> my_inbox = SMS_store()
        >>> my_inbox.messages
        []
        """
        self.messages = []
    
    def message_count(self):
        """Return the number of messages in the store
        
        >>> my_inbox = SMS_store()
        >>> my_inbox.message_count()
        0
        """
        return len(self.messages)
 
    def add_new_arrival(self, from_number, time_arrived, text_of_SMS):
        """Add a new SMS to the store
      
        Insert the new message on the end of messages. 
        The has_been_viewed status of the new message should be set to False.
        
        >>> my_inbox = SMS_store()
        >>> my_inbox.add_new_arrival('+420123456789', '12:34', 'Hello')
        >>> my_inbox.message_count()
        1
        >>> my_inbox.add_new_arrival('+420987654321', '21:43', 'Bye')
        >>> my_inbox.message_count()
        2
        """
        sms = (False, from_number, time_arrived, text_of_SMS)
        self.messages.append(sms)
 
    def __str__(self):
        """Return a printable representation of all the SMSs in the store
        
        >>> my_inbox = SMS_store()
        >>> my_inbox.add_new_arrival('+420123456789', '12:34', 'Hello')
        >>> my_inbox.add_new_arrival('+420987654321', '21:43', 'Bye')
        >>> print(my_inbox)
        * | +420123456789 | 12:34 | Hello
        * | +420987654321 | 21:43 | Bye
        """
        rows = []
        for sms in self.messages:
            rows.append(format_sms(sms))
        return '\n'.join(rows)

    def __add__(self, other):
        """Return a new SMS_store instance containing messages from both inboxes
        
        >>> my_inbox = SMS_store()
        >>> my_inbox.add_new_arrival('+420123456789', '12:34', 'Hello')
        >>> my_inbox.add_new_arrival('+420987654321', '21:43', 'Bye')
        >>> my_other_inbox = SMS_store()
        >>> my_inbox.add_new_arrival('+420123456789', '10:00', 'Foo')
        >>> my_inbox.add_new_arrival('+420987654321', '20:00', 'Bah')
        >>> my_new_inbox = my_inbox + my_other_inbox
        >>> print(my_new_inbox)
        * | +420123456789 | 12:34 | Hello
        * | +420987654321 | 21:43 | Bye
        * | +420123456789 | 10:00 | Foo
        * | +420987654321 | 20:00 | Bah
        """
        new = SMS_store()
        new.messages.extend(self.messages)
        new.messages.extend(other.messages)
        return new        
        
        
    def get_unread_indexes(self):
        """Return list of indexes of all not-yet-viewed SMS messages"""
 
    def get_message(self, i):
        """Return (from_number, time_arrived, text_of_sms) for i-th message.
        
        Set the has_been_viewed status to True.
        If no message at position i, return None.
        """

    def delete(self, i):
        """Delete message at position i"""
        
    def clear(self, i): 
        """Delete all messages"""
        
        
def format_sms(sms):
    """Return a string representation of a SMS
    
    >>> sms_internal = (False, '+420123456789', '12:34', 'Hello, Lucky!')
    >>> format_sms(sms_internal)
    '* | +420123456789 | 12:34 | Hello, Lucky!'
    """
    has_been_read, from_number, time_arrived, text_of_SMS = sms
    if not has_been_read:
        star = '*'
    else:
        star = ' '
    return ' | '.join([star, from_number, time_arrived, text_of_SMS])        
        
if __name__ == '__main__':
    doctest.testmod()