Skip to content

Commit

Permalink
Merge branch 'master' into add-pianopiece-command
Browse files Browse the repository at this point in the history
  • Loading branch information
IzN432 authored Oct 13, 2024
2 parents 8de06e4 + 4965119 commit 0aac585
Show file tree
Hide file tree
Showing 32 changed files with 373 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ src/test/data/sandbox/
docs/_site/
docs/_markbind/logs/
/bin/
/.vscode/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![CI Status](https://github.com/AY2425S1-CS2103T-T08-2/tp/workflows/Java%20CI/badge.svg)](https://github.com/AY2425S1-CS2103T-T08-2/tp/actions)
[![codecov](https://codecov.io/gh/AY2425S1-CS2103T-T08-2/tp/graph/badge.svg?token=BDD7P3MXJN)](https://codecov.io/gh/AY2425S1-CS2103T-T08-2/tp)
[![codecov](https://codecov.io/gh/AY2425S1-CS2103T-T08-2/tp/graph/badge.svg?token=BDD7P3MXJN)](https://codecov.io/gh/AY2425S1-CS2103T-T08-2/tp)
# KeyContacts

![Ui](docs/images/Ui.png)
Expand Down
6 changes: 3 additions & 3 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ _{Explain here how the data archiving feature will be implemented}_
* prefers typing to mouse interactions
* is reasonably comfortable using CLI apps

**Value proposition**:
**Value proposition**:
* Manage students' schedules faster than a typical mouse/GUI driven app
* Track income and the sale of learning materials, ensuring they get reimbursed while managing inventory effectively
* Accommodate students who need to reschedule, making for a flexible scheduling tool
* Track students' learning over time, enabling piano teachers to monitor students' grade and progress on piano pieces
* Track students' learning over time, enabling piano teachers to monitor students' grade and progress on piano pieces

### User stories

Expand Down Expand Up @@ -495,7 +495,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

### Non-Functional Requirements

1. **Cross-Platform Compatibility**: Should work on any _mainstream OS_ as long as it has Java `17` or above installed.
1. **Cross-Platform Compatibility**: Should work on any _mainstream OS_ as long as it has Java `17` or above installed.
2. **Performance**: Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage.
3. **Optimised for CLI Users**: A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.
4. **CLI Responsiveness**: Commands executed through the CLI should respond within 1 second under normal load (e.g. with 100 contacts).
Expand Down
8 changes: 4 additions & 4 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ Format: `help`

Adds a person to the address book.

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

<box type="tip" seamless>

**Tip:** A person can have any number of tags (including 0)
</box>

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] a/John street, block 123, #01-01 g/LCM 1`
* `add n/Betsy Crowe t/friend e/[email protected] a/Newgate Prison p/1234567 t/criminal g/ABRSM 1`

### Listing all persons : `list`

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

Edits an existing person in the address book.

Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…​`
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [g/GRADE_LEVEL] [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
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

![Ui](images/Ui.png)

**KeyContacts is a desktop application for home piano tutors to manager their students' information.**
**KeyContacts is a desktop application for home piano tutors to manager their students' information.**
While it has a GUI, most of the user interactions happen using a CLI (Command Line Interface).

* If you are interested in using KeyContacts, head over to the [_Quick Start_ section of the **User Guide**](UserGuide.html#quick-start).
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/keycontacts/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.util.Objects.requireNonNull;
import static keycontacts.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static keycontacts.logic.parser.CliSyntax.PREFIX_EMAIL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_GRADE_LEVEL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_NAME;
import static keycontacts.logic.parser.CliSyntax.PREFIX_PHONE;
import static keycontacts.logic.parser.CliSyntax.PREFIX_TAG;
Expand Down Expand Up @@ -32,6 +33,7 @@ public class AddCommand extends Command {
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_GRADE_LEVEL + "RSL 2 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";

Expand Down
32 changes: 23 additions & 9 deletions src/main/java/keycontacts/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.util.Objects.requireNonNull;
import static keycontacts.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static keycontacts.logic.parser.CliSyntax.PREFIX_EMAIL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_GRADE_LEVEL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_NAME;
import static keycontacts.logic.parser.CliSyntax.PREFIX_PHONE;
import static keycontacts.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -23,6 +24,7 @@
import keycontacts.model.Model;
import keycontacts.model.student.Address;
import keycontacts.model.student.Email;
import keycontacts.model.student.GradeLevel;
import keycontacts.model.student.Name;
import keycontacts.model.student.Phone;
import keycontacts.model.student.Student;
Expand All @@ -43,7 +45,8 @@ public class EditCommand extends Command {
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "[" + PREFIX_TAG + "TAG]..."
+ "[" + PREFIX_GRADE_LEVEL + "GRADE_LEVEL]\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]";
Expand Down Expand Up @@ -88,7 +91,6 @@ public CommandResult execute(Model model) throws CommandException {
return new CommandResult(String.format(MESSAGE_EDIT_STUDENT_SUCCESS, Messages.format(editedStudent)));
}


@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down Expand Up @@ -123,6 +125,7 @@ public static class EditStudentDescriptor {
private Email email;
private Address address;
private Set<Tag> tags;
private GradeLevel gradeLevel;

public EditStudentDescriptor() {}

Expand All @@ -136,13 +139,14 @@ public EditStudentDescriptor(EditStudentDescriptor toCopy) {
setEmail(toCopy.email);
setAddress(toCopy.address);
setTags(toCopy.tags);
setGradeLevel(toCopy.gradeLevel);
}

/**
* 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, address, tags, gradeLevel);
}

public void setName(Name name) {
Expand Down Expand Up @@ -177,6 +181,14 @@ public Optional<Address> getAddress() {
return Optional.ofNullable(address);
}

public void setGradeLevel(GradeLevel gradeLevel) {
this.gradeLevel = gradeLevel;
}

public Optional<GradeLevel> getGradeLevel() {
return Optional.ofNullable(gradeLevel);
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
Expand Down Expand Up @@ -205,12 +217,13 @@ public boolean equals(Object other) {
return false;
}

EditStudentDescriptor otherEditStudentDescriptor = (EditStudentDescriptor) other;
return Objects.equals(name, otherEditStudentDescriptor.name)
&& Objects.equals(phone, otherEditStudentDescriptor.phone)
&& Objects.equals(email, otherEditStudentDescriptor.email)
&& Objects.equals(address, otherEditStudentDescriptor.address)
&& Objects.equals(tags, otherEditStudentDescriptor.tags);
EditStudentDescriptor otherEditPersonDescriptor = (EditStudentDescriptor) other;
return Objects.equals(name, otherEditPersonDescriptor.name)
&& Objects.equals(phone, otherEditPersonDescriptor.phone)
&& Objects.equals(email, otherEditPersonDescriptor.email)
&& Objects.equals(address, otherEditPersonDescriptor.address)
&& Objects.equals(tags, otherEditPersonDescriptor.tags)
&& Objects.equals(gradeLevel, otherEditPersonDescriptor.gradeLevel);
}

@Override
Expand All @@ -221,6 +234,7 @@ public String toString() {
.add("email", email)
.add("address", address)
.add("tags", tags)
.add("gradeLevel", gradeLevel)
.toString();
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/keycontacts/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static keycontacts.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static keycontacts.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static keycontacts.logic.parser.CliSyntax.PREFIX_EMAIL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_GRADE_LEVEL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_NAME;
import static keycontacts.logic.parser.CliSyntax.PREFIX_PHONE;
import static keycontacts.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -13,6 +14,7 @@
import keycontacts.logic.parser.exceptions.ParseException;
import keycontacts.model.student.Address;
import keycontacts.model.student.Email;
import keycontacts.model.student.GradeLevel;
import keycontacts.model.student.Name;
import keycontacts.model.student.Phone;
import keycontacts.model.student.Student;
Expand All @@ -30,21 +32,24 @@ 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_ADDRESS, PREFIX_TAG,
PREFIX_GRADE_LEVEL);

if (!argMultimap.arePrefixesPresent(PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL)
if (!argMultimap.arePrefixesPresent(PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GRADE_LEVEL)
|| argMultimap.isPreamblePresent()) {
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_ADDRESS,
PREFIX_GRADE_LEVEL);
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());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
GradeLevel gradeLevel = ParserUtil.parseGradeLevel(argMultimap.getValue(PREFIX_GRADE_LEVEL).get());

Student student = new Student(name, phone, email, address, tagList);
Student student = new Student(name, phone, email, address, tagList, gradeLevel);

return new AddCommand(student);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/keycontacts/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public class CliSyntax {
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_ADDRESS = new Prefix("a/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_GRADE_LEVEL = new Prefix("g/");
public static final Prefix PREFIX_DAY = new Prefix("d/");
public static final Prefix PREFIX_START_TIME = new Prefix("st/");
public static final Prefix PREFIX_DATE = new Prefix("dt/");
public static final Prefix PREFIX_DAY = new Prefix("d/");
public static final Prefix PREFIX_END_TIME = new Prefix("et/");
public static final Prefix PREFIX_PIECE_NAME = new Prefix("pn/");
}
11 changes: 9 additions & 2 deletions src/main/java/keycontacts/logic/parser/EditCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static keycontacts.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static keycontacts.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static keycontacts.logic.parser.CliSyntax.PREFIX_EMAIL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_GRADE_LEVEL;
import static keycontacts.logic.parser.CliSyntax.PREFIX_NAME;
import static keycontacts.logic.parser.CliSyntax.PREFIX_PHONE;
import static keycontacts.logic.parser.CliSyntax.PREFIX_TAG;
Expand Down Expand Up @@ -32,7 +33,8 @@ 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_ADDRESS, PREFIX_TAG,
PREFIX_GRADE_LEVEL);

Index index;

Expand All @@ -42,7 +44,8 @@ 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_ADDRESS,
PREFIX_GRADE_LEVEL);

EditStudentDescriptor editStudentDescriptor = new EditStudentDescriptor();

Expand All @@ -58,6 +61,10 @@ public EditCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editStudentDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
if (argMultimap.getValue(PREFIX_GRADE_LEVEL).isPresent()) {
editStudentDescriptor.setGradeLevel(ParserUtil.parseGradeLevel(argMultimap.getValue(PREFIX_GRADE_LEVEL)
.get()));
}
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editStudentDescriptor::setTags);

if (!editStudentDescriptor.isAnyFieldEdited()) {
Expand Down
43 changes: 30 additions & 13 deletions src/main/java/keycontacts/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import keycontacts.model.pianopiece.PianoPiece;
import keycontacts.model.student.Address;
import keycontacts.model.student.Email;
import keycontacts.model.student.GradeLevel;
import keycontacts.model.student.Name;
import keycontacts.model.student.Phone;
import keycontacts.model.tag.Tag;
Expand Down Expand Up @@ -145,6 +146,34 @@ public static Tag parseTag(String tag) throws ParseException {
return new Tag(trimmedTag);
}

/**
* Parses {@code Collection<String> pianoPieces} into a {@code Set<PianoPiece>}.
*/
public static Set<PianoPiece> parsePianoPieces(Collection<String> pianoPieces) throws ParseException {
requireNonNull(pianoPieces);
final Set<PianoPiece> pianoPieceSet = new HashSet<>();
for (String pianoPieceName : pianoPieces) {
pianoPieceSet.add(parsePianoPiece(pianoPieceName));
}
return pianoPieceSet;
}

/**
* Parses a {@code String gradeLevel} into a {@code GradeLevel}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if the given {@code gradeLevel} is invalid.
*/
public static GradeLevel parseGradeLevel(String gradeLevel) throws ParseException {
requireNonNull(gradeLevel);
String trimmedGradeLevel = gradeLevel.trim();
if (!GradeLevel.isValidGradeLevel(trimmedGradeLevel)) {
throw new ParseException(GradeLevel.MESSAGE_CONSTRAINTS);
}

return new GradeLevel(trimmedGradeLevel);
}

/**
* Parses {@code Collection<String> tags} into a {@code Set<Tag>}.
*/
Expand All @@ -171,19 +200,7 @@ public static PianoPiece parsePianoPiece(String pianoPiece) throws ParseExceptio
}
return new PianoPiece(trimmedPianoPiece);
}

/**
* Parses {@code Collection<String> pianoPieces} into a {@code Set<PianoPiece>}.
*/
public static Set<PianoPiece> parsePianoPieces(Collection<String> pianoPieces) throws ParseException {
requireNonNull(pianoPieces);
final Set<PianoPiece> pianoPieceSet = new HashSet<>();
for (String pianoPieceName : pianoPieces) {
pianoPieceSet.add(parsePianoPiece(pianoPieceName));
}
return pianoPieceSet;
}


/**
* Parses {@code String date} into a {@code LocalDate}.
*/
Expand Down
Loading

0 comments on commit 0aac585

Please sign in to comment.