Commits

Steven! Ragnarök  committed acdf854

Fix some small bugs.

  • Participants
  • Parent commits 7eee8c1

Comments (0)

Files changed (2)

File src/main/java/com/nuclearsandwich/App.java

 			System.out.print(promptString);
 			String nextCommand = scanner.nextLine();
 			runCommand(nextCommand);
-			System.out.println("Command " + nextCommand);
 		}
 	}
 
 	public static void runCommand(String commandString) {
 		String[] commandAndArgString = commandString.split(" ", 2);
 		String command = commandAndArgString[0];
-		String argList = commandAndArgString[1];
+		String argList = "";
+		if (commandAndArgString.length > 1) {
+			argList = commandAndArgString[1];
+		}
 
-		System.out.println("Is a send: " + command.equals("send"));
-		System.out.println("Is an inbox: " + command.equals("inbox"));
-		System.out.println("Is a connect: " + command.equals("connect"));
-
-		if (command.equals("send")) {
+		if (command.equals("exit")) {
+			System.exit(0);
+		} else if (command.equals("send")) {
 			send(argList);
 		} else if (command.equals("inbox")) {
 			inbox(argList);
 	}
 
 	public static void send(String argList) {
-		String[] args = argList.split(" ", 2);
+		String[] args = argList.split(" ", 3);
 		User sender = User.by(args[0]);
 		User recipient = User.by(args[1]);
 		String body = args[2].replace("'", "");

File src/main/java/com/nuclearsandwich/Inbox.java

 package com.nuclearsandwich.messageme;
-import java.util.ArrayList;
+import java.util.LinkedList;
 
 public class Inbox {
 	public Inbox(User owner) {
 		this.owner = owner;
-		this.messages = new ArrayList<Message>();
+		this.messages = new LinkedList<Message>();
 	}
 
 	public void add(Message m) {
-		messages.add(m);
+		messages.push(m);
 	}
 
 	public void display() {
 	}
 
 	private User owner;
-	private ArrayList<Message> messages;
+	private LinkedList<Message> messages;
 }