package hello;

/**
 * Class that carries out actions
 * @author Zach Panzarino
 * @version 1.0.0
 */
public class Action {
    /**
     * Creates a new chat with matching id
     * @param number The phone number of the sender
     * @param content The content of the message
     */
    public static void create(String number, String content){
        String code = content.replaceAll("\\s+","");
        String key = code.substring(0, Math.min(20, code.length()));
        Selector selector = new Selector("jdbc:mysql://localhost:3306/Grouper", SQL.username, SQL.password);
        Inserter inserter = new Inserter("jdbc:mysql://localhost:3306/Grouper", SQL.username, SQL.password);
        ResultSet selected = selector.select("Name", "Chats", "Name='"+key+"'");
        while (selected.next()){
            if (selected.getString("Name") == key){
                (new SendSms(number, "Someone already has a chat with id: "+key+"\nIf you want to join this chat, run '/join "+key+"'")).sendSms();
                return;
            }
        }
        inserter.insert("Chats (Name, Admin)", "("+key+", "+number+")");
        (new SendSms(number, "You have created and joined a chat with id: "+key)).sendSms();
    }
    /**
     * Adds a user to a group of an existing id
     * @param number The phone number of the sender
     * @param content The content of the message
     */
    public static void join(String number, String content){
        String code = content.replaceAll("\\s+","");
        String key = code.substring(0, Math.min(20, code.length()));
    }
    /**
     * Sends a message to the group the user is in
     * @param number The phone number of the sender
     * @param content The content of the message
     */
    public static void message(String number, String content){
        String key = content.substring(0, Math.min(140, content.length()));
    }
    /**
     * Removes a user from his/her existing group
     * @param number The phone number of the sender
     */
    public static void leave(String number){
        
    }
}
@@ -1456,113 +1456,951 @@
 ring
- code = content.replaceAll(%22%5C%5Cs+%22,%22%22);%0A        String key = code.substring(0, Math.min(20, code.length())
+%5B%5D split = content.split(%22 %22);%0A        String key = split%5B0%5D.substring(0, Math.min(20, code.length()));%0A        String name = split%5B1%5D.substring(0, Math.min(18, code.length()));%0A        Selector selector = new Selector(%22jdbc:mysql://localhost:3306/Grouper%22, SQL.username, SQL.password);%0A        Inserter inserter = new Inserter(%22jdbc:mysql://localhost:3306/Grouper%22, SQL.username, SQL.password);%0A        ResultSet selected = selector.select(%22*%22, %22Chats%22, %22Name='%22+key+%22'%22);%0A        while (selected.next())%7B%0A            if (selected.getString(%22Name%22) == key)%7B%0A                inserter.insert(%22Users (Name, Number, Chat)%22, %22(%22+name+%22, %22+number+%22, %22+selected.getString(%22Name%22));%0A                (new SendSms(number, %22Hi, %22+name+%22, You have a chat with id: %22+key)).sendSms();%0A                return;%0A            %7D%0A        %7D%0A        (new SendSms(number, %22We couldn't find a chat with id: %22+key+%22%5CnTo create a chat, type '/create%22+key+%22'%22)).sendSms(
 );%0A 

Create join method