Skip to content

Commit

Permalink
Merge pull request #163 from agendazhang/master
Browse files Browse the repository at this point in the history
v1.4
  • Loading branch information
agendazhang authored Nov 6, 2018
2 parents 24bb191 + 434f869 commit 4d61268
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 30 deletions.
56 changes: 39 additions & 17 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ image::Ui.png[width="790"]
e.g. typing *`help`* and pressing kbd:[Enter] will open the help window.
. Some example commands you can try:

* *`listUser`* : lists all users in the event organiser
* *`listUser`* : lists all users in the Event Organiser
* **`addUser`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` : creates a new user named `John Doe` to the Event Organiser.
* `addEvent n/CS2103 Project Meeting a/SoC Canteen t/Urgent` : adds an event named CS2103 Project Meeting to be held at SoC Canteen.
* *`exit`* : exits the app
Expand Down Expand Up @@ -107,7 +107,7 @@ Examples:

==== List all users : `listUser`

Shows a list of all users in the event organiser. +
Shows a list of all users in the Event Organiser. +
Format: `listUser`

// tag::yaofeng(finduser)[]
Expand Down Expand Up @@ -135,7 +135,7 @@ Returns any user with the name `87438807` or email `john@example.com` or tag `te

==== Delete a user : `deleteUser`

Deletes the specified user from the event organiser. +
Deletes the specified user from the Event Organiser. +
Format: `deleteUser INDEX`

****
Expand All @@ -148,7 +148,7 @@ Examples:

* `listUser` +
`deleteUser 2` +
Deletes the 2nd user in the event organiser.
Deletes the 2nd user in the Event Organiser.
* `findUser Betsy` +
`deleteUser 1` +
Deletes the 1st user in the results of the `find` command.
Expand All @@ -168,14 +168,14 @@ Examples:

* `listUser` +
`selectUser 2` +
Selects the 2nd user in the event organiser.
Selects the 2nd user in the Event Organiser.
* `findUser Betsy` +
`selectUser 1` +
Selects the 1st user in the results of the `find` command.

==== Edit a user : `editUser`

Edits an existing user in the event organiser. +
Edits an existing user in the Event Organiser. +
Format: `editUser INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [i/INTEREST] [tt/TIMETABLE] [s/SCHEDULE] [su/SCHEDULE_UPDATE] ...`

[NOTE]
Expand All @@ -198,13 +198,16 @@ Edits the phone number and email address of the 1st user to be `91234567` and `j
* `editUser 2 n/Betsy Crower t/` +
Edits the name of the 2nd user to be `Betsy Crower` and clears all existing tags.

// tag::addDeleteFriend[]
==== Add a friend : `addFriend`

For two persons, adds friend with each other. +
Format: `addFriend INDEX,INDEX`

****
* For two users at the 2 specified `INDEX`, adds each other as friend. The index *must be a positive integer* 1, 2, 3, ... and must be different from each other
* For two users at the 2 specified `INDEX`, adds each other as friend.
* Only two indexes can be stated, seperated by a comma(,) with no spaces in between.
* Each index *must be a positive integer* 1, 2, 3, ..., and must be different from each other.
* The two users cannot be already friends.
****

Expand All @@ -219,14 +222,33 @@ For two persons, deletes each other as friend. +
Format: `deleteFriend INDEX,INDEX`

****
* For two users at the 2 specified `INDEX`, deletes each other as friend. The index *must be a positive integer* 1, 2, 3, ... and must be different from each other
* The two users must be already friends.
* For two users at the 2 specified `INDEX`, deletes each other as friend.
* Only two indexes can be stated, seperated by a comma(,) with no spaces in between.
* Each index *must be a positive integer* 1, 2, 3, ..., and must be different from each other.
* The two users must already be friends.
****
// end::addDeleteFriend[]

// tag::suggestFriends[]
==== Suggest friends based on similar interests : `suggestFriendsByInterests`

Suggest friends for an existing user in the Event Organiser that have at least one similar interest with the selected user. +
Format: `suggestFriendsByInterests INDEX`

****
* Suggests friends for the selected user at the specified `INDEX`.
* The index refers to the index number shown in the displayed user list.
* The index *must be a positive integer* 1, 2, 3, ...
* Users who have at least one similar interest with the selected user will be displayed.
* Users who are already friends with the selected user will not be displayed.
* The selected user will also be displayed, so that he/she can activate the `AddFriendCommand` immediately after that with the other displayed users.
****

Examples:

* `deleteFriend 1,2` +
1st and 2nd user are no longer friends with each other and their names are removed from each other's friend list.
* `suggestFriendsByInterests 1` +
Suggests friends for the 1st user in the Event Organiser that have at least one similar interest with the selected user.
// end::suggestFriends[]

// tag::maxschedule[]
==== Get free time between users : `maxSchedule`
Expand All @@ -244,7 +266,7 @@ Compares the schedule of users of index 1 and 2 and return a string of common fr
=== Create and confirm event commands

==== Create a new event : `addEvent`
Adds a new event to the event organiser. +
Adds a new event to the Event Organiser. +
Format: `addEvent n/NAME a/LOCATION t/TAGS`

Examples:
Expand All @@ -253,21 +275,21 @@ Examples:
* `addEvent n/CS1101S Meet-up a/UTown t/By invite`

==== Delete an event : `deleteEvent`
Deletes the specified event from the event organiser. +
Deletes the specified event from the Event Organiser. +
Format: `deleteEvent INDEX`

****
* Deletes the event at the specified `INDEX`.
* The index refers to the index number shown in the displayed user list.
* The index *must be a positive integer* 1, 2, 3, ...
* Event can only be deleted by the event organiser
* Event can only be deleted by the Event Organiser
****

Examples:

* `list` +
`deleteEvent 2` +
Deletes the 2nd event in the event organiser.
Deletes the 2nd event in the Event Organiser.

==== Select an event : `selectEvent`
Selects an event to be edited. +
Expand Down Expand Up @@ -360,7 +382,7 @@ Displays the poll with index 1 associated with the selected event.
=== Join event commands

==== Find event by the name of the event : `findEvent`
Finds events based on the attributes of the event: event name, event location, date, start time, event organiser, and event participants. +
Finds events based on the attributes of the event: event name, event location, date, start time, Event Organiser, and event participants. +
Format: `findEvent [e/EVENT_NAME] [a/LOCATION] [d/DATE] [t1/START_TIME] [on/ORGANISER_NAME] [pn/PARTICIPANT_NAME]`

Examples:
Expand Down Expand Up @@ -433,7 +455,7 @@ Format: `exit`

=== Saving the data

Event organiser data are saved in the hard disk automatically after any command that changes the data. +
Event Organiser data are saved in the hard disk automatically after any command that changes the data. +
There is no need to save manually.

== FAQ
Expand Down
53 changes: 53 additions & 0 deletions docs/team/agendazhang.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
= Zhang Cheng - Project Portfolio
:site-section: AboutUs
:imagesDir: ../images
:stylesDir: ../stylesheets

== PROJECT: EventOrganiser

---

== Overview

EventOrganiser is an application for managing and organising events built for NUS students. It is optimized for those
who prefer to work with a Command Line Interface (CLI) while still having the benefits of a Graphical User Interface (GUI).

== Summary of

* *Major enhancement*: Added the ability to specify friendships among users
** What it does: Allows the users to add or delete friends with each other and have their friend lists displayed
** Justification: This feature allows users to keep a friendship list which they can refer to it themselves when creating new events. For example, if they would like to organize a friends meetup, they will know who to add to the event. Also, it allows users to search for friends with common interests and expand their friendship lists.

* *Minor enhancement*: Added a new attribute Interest for a user
** Justification: This attribute allows users to specify any number of interests, which can be identified for friendships and events.

* *Code contributed*: [https://nus-cs2103-ay1819s1.github.io/cs2103-dashboard/#=undefined&search=agendazhang[Functional code]]

* *Other contributions*:

** Project management
** Enhancements to existing features:
*** Updated the GUI browser display (Pull request https://github.com/CS2103-AY1819S1-W10-3/main/pull/123[#123])
*** Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull request https://github.com/CS2103-AY1819S1-W10-3/main/pull/163[#163])
** Documentation:
*** Finalise User Stories: https://github.com/CS2103-AY1819S1-W10-3/main/pull/18[#18]
** Community:
*** PRs reviewed (with non-trivial review comments): https://github.com/CS2103-AY1819S1-W10-3/main/pull/164[#164], https://github.com/CS2103-AY1819S1-W10-3/main/pull/165[#165]
*** Reported bugs and suggestions for other teams in the class (No reference as it was done verbally with group W10-2)

== Contributions to the User Guide

|===
|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._
|===
include::../UserGuide.adoc[tag=addDeleteFriend]

include::../UserGuide.adoc[tag=suggestFriends]

== Contributions to the Developer Guide

|===
|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._
|===

include::../DeveloperGuide.adoc[tag=addDeleteFriend]
1 change: 1 addition & 0 deletions src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Messages {
public static final String MESSAGE_END_BEFORE_START_TIME = "The end time must come after the start time.";
public static final String MESSAGE_HAVE_NOT_JOINED = "You have yet to join this event.";
public static final String MESSAGE_HAVE_ALREADY_VOTED = "You have already voted for this option.";
public static final String MESSAGE_CANNOT_ADD_FRIEND_OWNSELF = "User cannot add/delete friends with ownself.";
public static final String MESSAGE_ALREADY_FRIENDS = "Both persons are already friends.";
public static final String MESSAGE_NOT_FRIENDS = "Both persons are not yet friends.";
public static final String MESSAGE_INVALID_DATE_RANGE = "This date range is invalid.";
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/seedu/address/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static String getDetails(Throwable t) {

/**
* Returns true if {@code s} represents a non-zero unsigned integer
* e.g. 1, 2, 3, ..., {@code Integer.MAX_VALUE} <br>
* e.g. 1, 2, 3, ..., {@code Integer.MAX_VALUE} seperated/not seperated by comma.<br>
* Will return false for any other non-null string input
* e.g. empty string, "-1", "0", "+1", and " 2 " (untrimmed), "3 0" (contains whitespace), "1 a" (contains letters)
* @throws NullPointerException if {@code s} is null.
Expand All @@ -64,7 +64,7 @@ public static boolean isNonZeroUnsignedInteger(String s) {
requireNonNull(s);
try {
ArrayList<Integer> values = new ArrayList<>();
if (s.contains(COMMA)) {
if (s.contains(COMMA) && countCommas(s) <= 1) { // check if more than two indexes are passed
values = splitIntegersWithComma(s);
} else {
values.add(Integer.parseInt(s));
Expand All @@ -86,10 +86,24 @@ public static boolean isNonZeroUnsignedInteger(String s) {
*/
public static ArrayList<Integer> splitIntegersWithComma(String s) throws NumberFormatException {
ArrayList<Integer> values = new ArrayList<>();
StringTokenizer st = new StringTokenizer(s, ",");
StringTokenizer st = new StringTokenizer(s, COMMA);
while (st.hasMoreTokens()) {
values.add(Integer.parseInt(st.nextToken()));
}
return values;
}

/**
* Given a string that separates two integers with a comma (eg "1,2,3"), this function returns
* the number of commas in the string.
*/
public static int countCommas(String s) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ',') {
count++;
}
}
return count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
List<Person> lastShownList = model.getFilteredPersonList();

if (indexes.getZeroBased() >= lastShownList.size()
|| indexes.getZeroBased2() >= lastShownList.size()
|| indexes.getZeroBased() == indexes.getZeroBased2()) {
|| indexes.getZeroBased2() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
if (indexes.getZeroBased() == indexes.getZeroBased2()) {
throw new CommandException(Messages.MESSAGE_CANNOT_ADD_FRIEND_OWNSELF);
}

Person person1 = lastShownList.get(indexes.getZeroBased());
Person person2 = lastShownList.get(indexes.getZeroBased2());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
List<Person> lastShownList = model.getFilteredPersonList();

if (indexes.getZeroBased() >= lastShownList.size()
|| indexes.getZeroBased2() >= lastShownList.size()
|| indexes.getZeroBased() == indexes.getZeroBased2()) {
|| indexes.getZeroBased2() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
if (indexes.getZeroBased() == indexes.getZeroBased2()) {
throw new CommandException(Messages.MESSAGE_CANNOT_ADD_FRIEND_OWNSELF);
}

Person person1 = lastShownList.get(indexes.getZeroBased());
Person person2 = lastShownList.get(indexes.getZeroBased2());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class SuggestFriendsByInterestsCommand extends Command {
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_LIST_SUGGESTED_FRIENDS_SUCCESS = "Listed all suggested friends for user: %1$s";
public static final String MESSAGE_LIST_SUGGESTED_FRIENDS_BY_INTERESTS_SUCCESS = "Listed all suggested friends"
+ " by interests for user: %1$s";

private final Index targetIndex;

Expand All @@ -53,7 +54,8 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
InterestSimilarPredicate predicate = new InterestSimilarPredicate(targetPerson);

model.updateFilteredPersonList(predicate);
return new CommandResult(String.format(MESSAGE_LIST_SUGGESTED_FRIENDS_SUCCESS, targetPerson.getName()));
return new CommandResult(String.format(MESSAGE_LIST_SUGGESTED_FRIENDS_BY_INTERESTS_SUCCESS,
targetPerson.getName()));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static Friend parseFriend(String friend) {
}

/**
* Parses a {@code String schedule} into a {@code Schedule}.
* Parses a {@code String} into a {@code Schedule}.
* @param schedule
*
* @throws ParseException
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/commons/util/StringUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public void isUnsignedPositiveInteger() {
// EP: 2 numbers(1 invalid) with comma in between, should return false
assertFalse(StringUtil.isNonZeroUnsignedInteger("0,2"));

// EP: 2 numbers with comma in between and white space, should return false
assertFalse(StringUtil.isNonZeroUnsignedInteger(" 0,2 "));
// EP: 3 numbers with comma in between, should return false
assertFalse(StringUtil.isNonZeroUnsignedInteger("1,2,3"));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ public void executeInvalidIndexUnfilteredListThrowsCommandException() {
assertCommandFailure(addFriendCommand, model, commandHistory, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

@Test
public void executeSameIndexUnfilteredListThrowsCommandException() {
Index sameIndexes = Index.fromOneBased(INDEX_SECOND.getZeroBased(), INDEX_SECOND.getZeroBased());
AddFriendCommand addFriendCommand = new AddFriendCommand(sameIndexes);

assertCommandFailure(addFriendCommand, model, commandHistory, Messages.MESSAGE_CANNOT_ADD_FRIEND_OWNSELF);
}

@Test
public void checkUpdatedFriendListsDueToEditedPerson() throws CommandException {
AddFriendCommand addFriendCommand = new AddFriendCommand(Index.fromZeroBased(INDEX_SECOND.getZeroBased(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public void executeInvalidIndexUnfilteredListThrowsCommandException() {
Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

@Test
public void executeSameIndexUnfilteredListThrowsCommandException() {
Index sameIndexes = Index.fromOneBased(INDEX_SECOND.getZeroBased(), INDEX_SECOND.getZeroBased());
DeleteFriendCommand deleteFriendCommand = new DeleteFriendCommand(sameIndexes);

assertCommandFailure(deleteFriendCommand, model, commandHistory, Messages.MESSAGE_CANNOT_ADD_FRIEND_OWNSELF);
}

@Test
public void equals() {
DeleteFriendCommand deleteFriendFirstCommand = new DeleteFriendCommand(Index.fromZeroBased(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void execute_validIndexUnfilteredList_success() {
Person targetPerson = model.getFilteredPersonList().get(INDEX_FIRST.getZeroBased());
SuggestFriendsByInterestsCommand suggestFriendsByInterestsCommand = new
SuggestFriendsByInterestsCommand(INDEX_FIRST);
String expectedMessage = String.format(SuggestFriendsByInterestsCommand.MESSAGE_LIST_SUGGESTED_FRIENDS_SUCCESS,
String expectedMessage = String.format(
SuggestFriendsByInterestsCommand.MESSAGE_LIST_SUGGESTED_FRIENDS_BY_INTERESTS_SUCCESS,
targetPerson.getName());

InterestSimilarPredicate predicate = new InterestSimilarPredicate(targetPerson);
Expand Down

0 comments on commit 4d61268

Please sign in to comment.