Skip to content

Commit

Permalink
Merge branch 'master' into add-availability-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
whitesnowx committed Mar 12, 2024
2 parents 3849391 + 831ebad commit 49b1ae1
Show file tree
Hide file tree
Showing 36 changed files with 306 additions and 306 deletions.
14 changes: 7 additions & 7 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ StaffConnect (SC) is a **desktop app for managing contacts of Professors and Tut

* `list` : Lists all contacts.

* `add n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` : Adds a contact named `John Doe` to the contacts list.
* `add n/John Doe p/98765432 e/[email protected] v/John street, block 123, #01-01` : Adds a contact named `John Doe` to the contacts list.

* `delete 3` : Deletes the 3rd contact shown in the current list.

Expand Down Expand Up @@ -76,15 +76,15 @@ Format: `help`

Adds a person to the contacts.

Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​`
Format: `add n/NAME p/PHONE_NUMBER e/EMAIL v/VENUE [t/TAG]…​`

<div markdown="span" class="alert alert-primary">:bulb: **Tip:**
A person can have any number of tags (including 0)
</div>

Examples:
* `add n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01`
* `add n/Betsy Crowe t/friend e/[email protected] a/Newgate Prison p/1234567 t/criminal`
* `add n/John Doe p/98765432 e/[email protected] v/John street, block 123, #01-01`
* `add n/Betsy Crowe t/friend e/[email protected] v/Newgate Prison p/1234567 t/criminal`

### Listing all persons : `list`

Expand All @@ -96,7 +96,7 @@ Format: `list`

Edits an existing person in the contacts.

Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [v/VENUE] [t/TAG]…​`

* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list. The index **must be a positive integer** 1, 2, 3, …​
* At least one of the optional fields must be provided.
Expand Down Expand Up @@ -189,10 +189,10 @@ _Details coming soon ..._

Action | Format, Examples
--------|------------------
**Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 t/friend t/colleague`
**Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL v/VENUE [t/TAG]…​` <br> e.g., `add n/James Ho p/22224444 e/[email protected] v/123, Clementi Rd, 1234665 t/friend t/colleague`
**Clear** | `clear`
**Delete** | `delete INDEX`<br> e.g., `delete 3`
**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`<br> e.g.,`edit 2 n/James Lee e/[email protected]`
**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [v/VENUE] [t/TAG]…​`<br> e.g.,`edit 2 n/James Lee e/[email protected]`
**Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake`
**List** | `list`
**Help** | `help`
4 changes: 2 additions & 2 deletions src/main/java/staffconnect/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static String format(Person person) {
.append(person.getPhone())
.append("; Email: ")
.append(person.getEmail())
.append("; Address: ")
.append(person.getAddress())
.append("; Venue: ")
.append(person.getVenue())
.append("; Tags: ");
person.getTags().forEach(builder::append);
return builder.toString();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/staffconnect/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package staffconnect.logic.commands;

import static java.util.Objects.requireNonNull;
import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL;
import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME;
import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE;
import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG;
import static staffconnect.logic.parser.CliSyntax.PREFIX_VENUE;

import staffconnect.commons.util.ToStringBuilder;
import staffconnect.logic.Messages;
Expand All @@ -25,13 +25,13 @@ public class AddCommand extends Command {
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_VENUE + "VENUE "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_VENUE + "311, Clementi Ave 2, #02-25 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/staffconnect/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package staffconnect.logic.commands;

import static java.util.Objects.requireNonNull;
import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL;
import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME;
import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE;
import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG;
import static staffconnect.logic.parser.CliSyntax.PREFIX_VENUE;
import static staffconnect.model.Model.PREDICATE_SHOW_ALL_PERSONS;

import java.util.Collections;
Expand All @@ -21,11 +21,11 @@
import staffconnect.logic.Messages;
import staffconnect.logic.commands.exceptions.CommandException;
import staffconnect.model.Model;
import staffconnect.model.person.Address;
import staffconnect.model.person.Email;
import staffconnect.model.person.Name;
import staffconnect.model.person.Person;
import staffconnect.model.person.Phone;
import staffconnect.model.person.Venue;
import staffconnect.model.tag.Tag;

/**
Expand All @@ -42,7 +42,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_NAME + "NAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_VENUE + "VENUE] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
Expand Down Expand Up @@ -98,10 +98,10 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName());
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail());
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Venue updatedVenue = editPersonDescriptor.getVenue().orElse(personToEdit.getVenue());
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags);
return new Person(updatedName, updatedPhone, updatedEmail, updatedVenue, updatedTags);
}

@Override
Expand Down Expand Up @@ -136,7 +136,7 @@ public static class EditPersonDescriptor {
private Name name;
private Phone phone;
private Email email;
private Address address;
private Venue venue;
private Set<Tag> tags;

public EditPersonDescriptor() {}
Expand All @@ -149,15 +149,15 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setName(toCopy.name);
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
setVenue(toCopy.venue);
setTags(toCopy.tags);
}

/**
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address, tags);
return CollectionUtil.isAnyNonNull(name, phone, email, venue, tags);
}

public void setName(Name name) {
Expand All @@ -184,12 +184,12 @@ public Optional<Email> getEmail() {
return Optional.ofNullable(email);
}

public void setAddress(Address address) {
this.address = address;
public void setVenue(Venue venue) {
this.venue = venue;
}

public Optional<Address> getAddress() {
return Optional.ofNullable(address);
public Optional<Venue> getVenue() {
return Optional.ofNullable(venue);
}

/**
Expand Down Expand Up @@ -224,7 +224,7 @@ public boolean equals(Object other) {
return Objects.equals(name, otherEditPersonDescriptor.name)
&& Objects.equals(phone, otherEditPersonDescriptor.phone)
&& Objects.equals(email, otherEditPersonDescriptor.email)
&& Objects.equals(address, otherEditPersonDescriptor.address)
&& Objects.equals(venue, otherEditPersonDescriptor.venue)
&& Objects.equals(tags, otherEditPersonDescriptor.tags);
}

Expand All @@ -234,7 +234,7 @@ public String toString() {
.add("name", name)
.add("phone", phone)
.add("email", email)
.add("address", address)
.add("venue", venue)
.add("tags", tags)
.toString();
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/staffconnect/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package staffconnect.logic.parser;

import static staffconnect.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL;
import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME;
import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE;
import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG;
import static staffconnect.logic.parser.CliSyntax.PREFIX_VENUE;

import java.util.Set;
import java.util.stream.Stream;

import staffconnect.logic.commands.AddCommand;
import staffconnect.logic.parser.exceptions.ParseException;
import staffconnect.model.person.Address;
import staffconnect.model.person.Email;
import staffconnect.model.person.Name;
import staffconnect.model.person.Person;
import staffconnect.model.person.Phone;
import staffconnect.model.person.Venue;
import staffconnect.model.tag.Tag;

/**
Expand All @@ -31,21 +31,21 @@ public class AddCommandParser implements Parser<AddCommand> {
*/
public AddCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG);
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_VENUE, PREFIX_TAG);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL)
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_VENUE, PREFIX_PHONE, PREFIX_EMAIL)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS);
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_VENUE);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Venue venue = ParserUtil.parseVenue(argMultimap.getValue(PREFIX_VENUE).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Person person = new Person(name, phone, email, address, tagList);
Person person = new Person(name, phone, email, venue, tagList);

return new AddCommand(person);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class CliSyntax {
public static final Prefix PREFIX_NAME = new Prefix("n/");
public static final Prefix PREFIX_PHONE = new Prefix("p/");
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_ADDRESS = new Prefix("a/");
public static final Prefix PREFIX_VENUE = new Prefix("v/");
public static final Prefix PREFIX_TAG = new Prefix("t/");

}
10 changes: 5 additions & 5 deletions src/main/java/staffconnect/logic/parser/EditCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static java.util.Objects.requireNonNull;
import static staffconnect.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL;
import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME;
import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE;
import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG;
import static staffconnect.logic.parser.CliSyntax.PREFIX_VENUE;

import java.util.Collection;
import java.util.Collections;
Expand All @@ -32,7 +32,7 @@ public class EditCommandParser implements Parser<EditCommand> {
public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG);
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_VENUE, PREFIX_TAG);

Index index;

Expand All @@ -42,7 +42,7 @@ public EditCommand parse(String args) throws ParseException {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe);
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS);
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_VENUE);

EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();

Expand All @@ -55,8 +55,8 @@ public EditCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
}
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
if (argMultimap.getValue(PREFIX_VENUE).isPresent()) {
editPersonDescriptor.setVenue(ParserUtil.parseVenue(argMultimap.getValue(PREFIX_VENUE).get()));
}
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/staffconnect/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import staffconnect.commons.core.index.Index;
import staffconnect.commons.util.StringUtil;
import staffconnect.logic.parser.exceptions.ParseException;
import staffconnect.model.person.Address;
import staffconnect.model.person.Email;
import staffconnect.model.person.Name;
import staffconnect.model.person.Phone;
import staffconnect.model.person.Venue;
import staffconnect.model.tag.Tag;

/**
Expand Down Expand Up @@ -66,18 +66,18 @@ public static Phone parsePhone(String phone) throws ParseException {
}

/**
* Parses a {@code String address} into an {@code Address}.
* Parses a {@code String venue} into an {@code Venue}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if the given {@code address} is invalid.
* @throws ParseException if the given {@code venue} is invalid.
*/
public static Address parseAddress(String address) throws ParseException {
requireNonNull(address);
String trimmedAddress = address.trim();
if (!Address.isValidAddress(trimmedAddress)) {
throw new ParseException(Address.MESSAGE_CONSTRAINTS);
public static Venue parseVenue(String venue) throws ParseException {
requireNonNull(venue);
String trimmedVenue = venue.trim();
if (!Venue.isValidVenue(trimmedVenue)) {
throw new ParseException(Venue.MESSAGE_CONSTRAINTS);
}
return new Address(trimmedAddress);
return new Venue(trimmedVenue);
}

/**
Expand Down
Loading

0 comments on commit 49b1ae1

Please sign in to comment.