forked from se-edu/addressbook-level2
-
Notifications
You must be signed in to change notification settings - Fork 35
[W5][T09-2]Wan Chunwei #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Wanchunwei
wants to merge
5
commits into
nusCS2113-AY1819S2:master
Choose a base branch
from
Wanchunwei:W5.1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="src" path="src"/> | ||
| <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>AddressBook-Level2</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| <buildCommand> | ||
| <name>org.eclipse.wst.common.project.facet.core.builder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
|
|
||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.wst.common.project.facet.core.nature</nature> | ||
| <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> | ||
| <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>src</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| </buildSpec> | ||
| <natures> | ||
| </natures> | ||
| </projectDescription> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <classpath> | ||
| <classpathentry kind="src" path=""/> | ||
| <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
| <classpathentry kind="output" path="bin"/> | ||
| </classpath> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <projectDescription> | ||
| <name>addressbook</name> | ||
| <comment></comment> | ||
| <projects> | ||
| </projects> | ||
| <buildSpec> | ||
| <buildCommand> | ||
| <name>org.eclipse.jdt.core.javabuilder</name> | ||
| <arguments> | ||
| </arguments> | ||
| </buildCommand> | ||
| </buildSpec> | ||
| <natures> | ||
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| </natures> | ||
| </projectDescription> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<ReadOnlyPerson> allPersons = null; | ||
| try { | ||
| allPersons = addressBook.getSortedPersons().immutableListView(); | ||
| } catch (DuplicatePersonException e) { | ||
| // TODO Auto-generated catch block | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons); | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<Name> { | ||
|
|
||
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the Java Coding Standards which can be found on the module website for the correct format for if-else statements. |
||
| } | ||
| else { | ||
| return 0; | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add a header comment that explains what the Sort Command does to the user.