(**
 * This file defines objects and operations pertinent to the EClass Chat.
 *)


module Chat;

export Chat;

obj Chat is
    components: Channel*;
    description: (*
        A Chat is the top level object in the Chat program.  It is composed of one or more channels.
    *);
end Chat;

obj Channel is
    components: Person*, MessageList;
    description: (*
       A Channel is made up of one or more Person Objects which represent the people in a Channel.
       A Channel can have two Persons in it (one on one chat) or it could have more than two (group chat).
       The MessageList represents the collection of messages that have been entered by Persons in teh Channel.
    *);
end Channel;

obj Person is
    components: UserID;
    description: (*
       A Person represents a user involved in a chat.  The UserID is the user's computer ID.
    *);
end Person;

obj MessageList is
    components: Message*;
    description: (*
       An collection of the messages inside a Channel.  This collection can be viewed and updated by Persons
       in the Channel.
    *);
end MessageList;

obj Message is
    components: UserID, Text;
    description: (*
       An object containing a user ID and a string that can be added to the MessageList inside a Channel
    *);
end Message;

obj UserID is string;
obj Text is string;


operation ChangeTextSize
    inputs: t:Text;
    outputs: t':Text;
    precondition: (t != nil);
    postcondition: (* Coming Soon *);
    description: (*
        ChangeTextSize increases or decrease the font size of the meesage that will be send
    *);
end ChangeTextSize;

operation Highlight
    inputs: Text;
    outputs: Text;
    precondition: (* Coming Soon *);
    postcondition: (* Coming Soon *);
    description: (*
        Changes the background color of the input string
    *);

end Highlight;

operation SpellCheck
    inputs: Text;
    outputs: Text;
    precondition: (* Coming Soon *);
    postcondition: (* Coming Soon *);
    description: (*
        SpellCheck returns a string with and underline style to any strings within the input not recongized by the program
    *);
end SpellCheck;

operation SendMessage
    inputs: m:Message, ml:MessageList;
    outputs: ml':MessageList;
    precondition: (m != nil);
    postcondition: (* (m in ml') and (ml'.length = ml.length + 1); *);
    description: (*
        This operation adds a Message to the Channel's MessageList for all Persons in the Channel to view
    *);
end SendMessage;

operation CreateChannel
    inputs: p:Person*, m:MessageList;
    outputs: c:Channel;
    precondition:(* There are at least two Persons *);
    postcondition: (c != nil);
    description: (*
        This operation takes at least two Persons and create a channel where the Persons can send and recieve messages 
    *);
end CreateChannel;

operation JoinChannel
    inputs: p:Person, c:Channel;
    outputs: c':Channel;
    precondition: (c != nil);
    postcondition: (* (p in c') and (c'.length = c.length + 1); *);
    description: (*
        This operation takes a Person object and adds it to a Channel object that is already in existants 
    *);
end JoinChannel;

end Chat;