diff --git a/.classpath b/.classpath
new file mode 100644
index 000000000..9b07da8c9
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 000000000..453f51004
--- /dev/null
+++ b/.project
@@ -0,0 +1,26 @@
+
+
+ AddressBook-Level2
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.nature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..ccb99a9ec
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,142 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
+org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL
+org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/.settings/org.eclipse.jdt.launching.prefs b/.settings/org.eclipse.jdt.launching.prefs
new file mode 100644
index 000000000..f8a131b56
--- /dev/null
+++ b/.settings/org.eclipse.jdt.launching.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
diff --git a/src/.project b/src/.project
new file mode 100644
index 000000000..f7d6de678
--- /dev/null
+++ b/src/.project
@@ -0,0 +1,11 @@
+
+
+ src
+
+
+
+
+
+
+
+
diff --git a/src/seedu/addressbook/.classpath b/src/seedu/addressbook/.classpath
new file mode 100644
index 000000000..31a928169
--- /dev/null
+++ b/src/seedu/addressbook/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/src/seedu/addressbook/.project b/src/seedu/addressbook/.project
new file mode 100644
index 000000000..4132fe9ac
--- /dev/null
+++ b/src/seedu/addressbook/.project
@@ -0,0 +1,17 @@
+
+
+ addressbook
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java
index 2ff8f1575..b15cadc90 100644
--- a/src/seedu/addressbook/commands/Command.java
+++ b/src/seedu/addressbook/commands/Command.java
@@ -3,6 +3,7 @@
import seedu.addressbook.common.Messages;
import seedu.addressbook.data.AddressBook;
import seedu.addressbook.data.person.ReadOnlyPerson;
+import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException;
import java.util.List;
@@ -38,8 +39,9 @@ public static String getMessageForPersonListShownSummary(List extends ReadOnly
/**
* Executes the command and returns the result.
+ *
*/
- public CommandResult execute(){
+ public CommandResult execute() throws DuplicatePersonException{
throw new UnsupportedOperationException("This method is to be implemented by child classes");
};
@@ -63,7 +65,8 @@ protected ReadOnlyPerson getTargetPerson() throws IndexOutOfBoundsException {
public int getTargetIndex() {
return targetIndex;
}
-
+
+
public void setTargetIndex(int targetIndex) {
this.targetIndex = targetIndex;
}
diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java
index 9be217d89..3a7992589 100644
--- a/src/seedu/addressbook/commands/HelpCommand.java
+++ b/src/seedu/addressbook/commands/HelpCommand.java
@@ -23,6 +23,7 @@ public CommandResult execute() {
+ "\n" + ViewAllCommand.MESSAGE_USAGE
+ "\n" + HelpCommand.MESSAGE_USAGE
+ "\n" + ExitCommand.MESSAGE_USAGE
+ + "\n" + SortCommand.MESSAGE_USAGE
);
}
}
diff --git a/src/seedu/addressbook/commands/ListCommand.java b/src/seedu/addressbook/commands/ListCommand.java
index d76d48297..30a9e744c 100644
--- a/src/seedu/addressbook/commands/ListCommand.java
+++ b/src/seedu/addressbook/commands/ListCommand.java
@@ -1,5 +1,6 @@
package seedu.addressbook.commands;
+import seedu.addressbook.data.person.Person;
import seedu.addressbook.data.person.ReadOnlyPerson;
import java.util.List;
diff --git a/src/seedu/addressbook/commands/SortCommand.java b/src/seedu/addressbook/commands/SortCommand.java
new file mode 100644
index 000000000..e2052f098
--- /dev/null
+++ b/src/seedu/addressbook/commands/SortCommand.java
@@ -0,0 +1,44 @@
+package seedu.addressbook.commands;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import com.sun.corba.se.impl.encoding.OSFCodeSetRegistry.Entry;
+import com.sun.javafx.collections.MappingChange.Map;
+
+import seedu.addressbook.data.person.Person;
+import seedu.addressbook.data.person.ReadOnlyPerson;
+import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException;
+
+public class SortCommand extends Command{
+ public static final String COMMAND_WORD = "Sort";
+
+ public static final String MESSAGE_USAGE = COMMAND_WORD
+ + ": Sort all persons in the address book by their name.\n"
+ + "Example: " + COMMAND_WORD;
+
+
+ @Override
+ public CommandResult execute() {
+ List allPersons = null;
+ try {
+ allPersons = addressBook.getSortedPersons().immutableListView();
+ } catch (DuplicatePersonException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons);
+ }
+
+
+
+
+}
diff --git a/src/seedu/addressbook/data/AddressBook.java b/src/seedu/addressbook/data/AddressBook.java
index 537d35c89..9878eb453 100644
--- a/src/seedu/addressbook/data/AddressBook.java
+++ b/src/seedu/addressbook/data/AddressBook.java
@@ -1,5 +1,9 @@
package seedu.addressbook.data;
+import java.util.Collections;
+
+import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
+
import seedu.addressbook.data.person.Person;
import seedu.addressbook.data.person.ReadOnlyPerson;
import seedu.addressbook.data.person.UniquePersonList;
@@ -67,11 +71,16 @@ public void clear() {
public UniquePersonList getAllPersons() {
return new UniquePersonList(allPersons);
}
-
+
@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof AddressBook // instanceof handles nulls
&& this.allPersons.equals(((AddressBook) other).allPersons));
}
+
+ public UniquePersonList getSortedPersons() throws DuplicatePersonException {
+ allPersons.sort();
+ return new UniquePersonList(allPersons);
+ }
}
diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java
index d1d271414..cf15c10ea 100644
--- a/src/seedu/addressbook/data/person/Name.java
+++ b/src/seedu/addressbook/data/person/Name.java
@@ -9,7 +9,7 @@
* Represents a Person's name in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)}
*/
-public class Name {
+public class Name implements Comparable {
public static final String EXAMPLE = "John Doe";
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphabetic characters";
@@ -59,5 +59,20 @@ public boolean equals(Object other) {
public int hashCode() {
return fullName.hashCode();
}
+
+ @Override
+ public int compareTo(Name o) {
+ if(this.fullName.compareTo(o.fullName) > 0) {
+ return 1;
+ }
+ else if(this.fullName.compareTo(o.fullName) < 0) {
+ return -1;
+ }
+ else {
+ return 0;
+ }
+
+ }
+
}
diff --git a/src/seedu/addressbook/data/person/Person.java b/src/seedu/addressbook/data/person/Person.java
index 64551c7fe..33e982f8d 100644
--- a/src/seedu/addressbook/data/person/Person.java
+++ b/src/seedu/addressbook/data/person/Person.java
@@ -1,5 +1,6 @@
package seedu.addressbook.data.person;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@@ -10,7 +11,7 @@
* Represents a Person in the address book.
* Guarantees: details are present and not null, field values are validated.
*/
-public class Person implements ReadOnlyPerson {
+public class Person implements ReadOnlyPerson,Comparable{
private Name name;
private Phone phone;
@@ -88,4 +89,19 @@ public String toString() {
return getAsTextShowAll();
}
+ @Override
+ public int compareTo(Person o) {
+ if(this.getName().compareTo(o.getName()) > 0) {
+ return 1;
+ }
+ else if(this.getName().compareTo(o.getName()) < 0) {
+ return -1;
+ }else {
+ return 0;
+ }
+
+ }
+
+
+
}
diff --git a/src/seedu/addressbook/data/person/ReadOnlyPerson.java b/src/seedu/addressbook/data/person/ReadOnlyPerson.java
index 1493f0a2b..4598dbd3c 100644
--- a/src/seedu/addressbook/data/person/ReadOnlyPerson.java
+++ b/src/seedu/addressbook/data/person/ReadOnlyPerson.java
@@ -8,7 +8,7 @@
* A read-only immutable interface for a Person in the addressbook.
* Implementations should guarantee: details are present and not null, field values are validated.
*/
-public interface ReadOnlyPerson {
+public interface ReadOnlyPerson{
Name getName();
Phone getPhone();
@@ -31,6 +31,7 @@ default boolean isSamePerson(ReadOnlyPerson other) {
&& other.getPhone().equals(this.getPhone()));
}
+
/**
* Returns true if all data in this object is the same as that in another
* (Note: interfaces cannot override .equals)
diff --git a/src/seedu/addressbook/data/person/UniquePersonList.java b/src/seedu/addressbook/data/person/UniquePersonList.java
index d7acd8b4a..4c8d58401 100644
--- a/src/seedu/addressbook/data/person/UniquePersonList.java
+++ b/src/seedu/addressbook/data/person/UniquePersonList.java
@@ -4,6 +4,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -18,7 +19,7 @@
* @see Person#equals(Object)
* @see Utils#elementsAreUnique(Collection)
*/
-public class UniquePersonList implements Iterable {
+public class UniquePersonList implements Iterable{
/**
* Signals that an operation would have violated the 'no duplicates' property of the list.
@@ -140,4 +141,25 @@ public boolean equals(Object other) {
|| (other instanceof UniquePersonList // instanceof handles nulls
&& this.internalList.equals(((UniquePersonList) other).internalList));
}
+
+ public List sort(){
+ Collections.sort(internalList, new Comparator() {
+ public int compare(Person o1, Person o2) {
+ if(o1.getName().compareTo(o2.getName()) > 0) {
+ return 1;
+ }
+ else if(o1.getName().compareTo(o2.getName()) < 0) {
+ return -1;
+ }
+ else {
+ return 0;
+ }
+
+ }
+ });
+ return internalList;
+
+ }
+
+
}
diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java
index abddb3f45..5b604f4eb 100644
--- a/src/seedu/addressbook/parser/Parser.java
+++ b/src/seedu/addressbook/parser/Parser.java
@@ -20,6 +20,7 @@
import seedu.addressbook.commands.HelpCommand;
import seedu.addressbook.commands.IncorrectCommand;
import seedu.addressbook.commands.ListCommand;
+import seedu.addressbook.commands.SortCommand;
import seedu.addressbook.commands.ViewAllCommand;
import seedu.addressbook.commands.ViewCommand;
import seedu.addressbook.data.exception.IllegalValueException;
@@ -96,6 +97,9 @@ public Command parseCommand(String userInput) {
case ExitCommand.COMMAND_WORD:
return new ExitCommand();
+
+ case SortCommand.COMMAND_WORD:
+ return new SortCommand();
case HelpCommand.COMMAND_WORD: // Fallthrough
default:
diff --git a/src/seedu/addressbook/Main.java b/src/src/seedu/addressbook/Main.java
similarity index 99%
rename from src/seedu/addressbook/Main.java
rename to src/src/seedu/addressbook/Main.java
index bc18bed7e..0dcf0f941 100644
--- a/src/seedu/addressbook/Main.java
+++ b/src/src/seedu/addressbook/Main.java
@@ -1,4 +1,4 @@
-package seedu.addressbook;
+package src.seedu.addressbook;
import java.util.Collections;
import java.util.List;
@@ -21,7 +21,6 @@
* Initializes the application and starts the interaction with the user.
*/
public class Main {
-
/** Version info of the program. */
public static final String VERSION = "AddressBook Level 2 - Version 1.0";
@@ -72,6 +71,9 @@ private void start(String[] launchArgs) {
}
}
+
+
+
/** Prints the Goodbye message and exits. */
private void exit() {
ui.showGoodbyeMessage();
diff --git a/test/expected.txt b/test/expected.txt
index 56fe5fcac..28a1f3889 100644
--- a/test/expected.txt
+++ b/test/expected.txt
@@ -290,6 +290,29 @@
||
|| 2 persons listed!
|| ===================================================
+|| Enter command: || [Command entered: Sort]
+|| 1. Betsy Choo Tags: [secretive]
+|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
+||
+|| 2 persons listed!
+|| ===================================================
+|| Enter command: || [Command entered: add Charlie Dickson pp/333333 e/charlie.d@nus.edu.sg a/333, gamma street t/friends t/school]
+|| New person added: Charlie Dickson Phone: (private) 333333 Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends]
+|| ===================================================
+|| Enter command: || [Command entered: list]
+|| 1. Betsy Choo Tags: [secretive]
+|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
+|| 3.Charlie Dickson Phone: (private) 333333 Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends]
+||
+|| 3 persons listed!
+|| ===================================================
+|| Enter command: || [Command entered: Sort]
+|| 1. Betsy Choo Tags: [secretive]
+|| 2. Dickson Ee Phone: 444444 Address: 444, delta street Tags: [friends]
+|| 3.Charlie Dickson Phone: (private) 333333 Email: charlie.d@nus.edu.sg Address: 333, gamma street Tags: [school][friends]
+||
+|| 3 persons listed!
+|| ===================================================
|| Enter command: || [Command entered: clear]
|| Address book has been cleared!
|| ===================================================
diff --git a/test/input.txt b/test/input.txt
index eb8df81f8..96d6e1001 100644
--- a/test/input.txt
+++ b/test/input.txt
@@ -139,6 +139,17 @@
# listing indexes get updated on next request
delete 1
list
+##########################################################
+# test Sort command
+##########################################################
+ # Sort Person by their name
+ Sort
+ list
+
+ #Add a new person to check Sort
+ add Charlie Dickson pp/333333 e/charlie.d@nus.edu.sg a/333, gamma street t/friends t/school
+ list
+ sort
##########################################################
# test clear command