Skip to content
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

Added Lesson and Subject classes #41

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,33 +291,33 @@ with TutorTrack – the ultimate solution for private tutors.

Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unlikely to have) - `*`

| Priority | As a …​ | I want to …​ | So that I can…​ |
|----------|-----------------|-----------------------------------|---------------------------|
| `* * *` | new user | view a guide of useful commands | refer to instructions when I forget how to use TutorTrack |
| `* * *` | freelance tutor | add a new student | |
| `* * *` | freelance tutor | delete an existing | remove entries that I no longer need |
| `* * *` | freelance tutor | find a student by name | locate details of persons without having to go through the entire list |
| `* *` | freelance tutor | view all my students' information | view all my students at the same time |
| `* * *` | freelance tutor | view a specific student's information | specifically refer to a particular student's information |
| `* *` | freelance tutor | edit student information | student information can be edited and changed |
| `* *` | freelance tutor | schedule meeting times with students | set lessons |
| `* * *` | freelance tutor | delete meeting times with students | cancel lessons |
| `* *` | freelance tutor | edit meeting times with students | reschedule lessons |
| `* *` | freelance tutor | view meeting times in a calender view with students | track when I have scheduled lessons |
| `*` | freelance tutor | mark attendance for each week | keep an accurate record of student attendance and participation over time |
| `*` | freelance tutor | edit milestones on the progress tracker | change milestone plans anytime |
| `* *` | freelance tutor | add milestones to a progress tracker | keep track of topics covered |
| `*` | student | access a summary page with my progress information | keep track of my progress |
| `*` | freelance tutor | view my schedule in a calendar form | keep track of lessons for the week/day |
| `*` | freelance tutor | view a progress tracking meter | have a visual representation of a students progress |
| `* *` | new user | create account using email | have an account that stores all the information |
| `* *` | registered user | login to my account | all the information is tracked and stored properly in the account |
| `* *` | freelance tutor | upload files and materials | students can access to them |
| `*` | student | download files and materials | review and revise the materials |
| `*` | freelance tutor | send message to students | chat with them |
| `*` | student | receive message from tutor | be informed with any announcements |
| `*` | student | receive notification from messages | be aware of messages send by tutors |
| `*` | freelance tutor | note down basic lesson plans (remarks) for each lesson | have a structure to follow for each lesson |
| Priority | As a …​ | I want to …​ | So that I can…​ |
|----------|-----------------|--------------------------------------------------------|---------------------------------------------------------------------------|
| `* * *` | new user | view a guide of useful commands | refer to instructions when I forget how to use TutorTrack |
| `* * *` | freelance tutor | add a new student | |
| `* * *` | freelance tutor | delete an existing | remove entries that I no longer need |
| `* * *` | freelance tutor | find a student by name | locate details of persons without having to go through the entire list |
| `* *` | freelance tutor | view all my students' information | view all my students at the same time |
| `* * *` | freelance tutor | view a specific student's information | specifically refer to a particular student's information |
| `* *` | freelance tutor | edit student information | student information can be edited and changed |
| `* *` | freelance tutor | schedule meeting times with students | set lessons |
| `* * *` | freelance tutor | delete meeting times with students | cancel lessons |
| `* *` | freelance tutor | edit meeting times with students | reschedule lessons |
| `* *` | freelance tutor | view meeting times in a calender view with students | track when I have scheduled lessons |
| `*` | freelance tutor | mark attendance for each week | keep an accurate record of student attendance and participation over time |
| `*` | freelance tutor | edit milestones on the progress tracker | change milestone plans anytime |
| `* *` | freelance tutor | add milestones to a progress tracker | keep track of topics covered |
| `*` | student | access a summary page with my progress information | keep track of my progress |
| `*` | freelance tutor | view my schedule in a calendar form | keep track of lessons for the week/day |
| `*` | freelance tutor | view a progress tracking meter | have a visual representation of a students progress |
| `* *` | new user | create account using email | have an account that stores all the information |
| `* *` | registered user | login to my account | all the information is tracked and stored properly in the account |
| `* *` | freelance tutor | upload files and materials | students can access to them |
| `*` | student | download files and materials | review and revise the materials |
| `*` | freelance tutor | send message to students | chat with them |
| `*` | student | receive message from tutor | be informed with any announcements |
| `*` | student | receive notification from messages | be aware of messages send by tutors |
| `*` | freelance tutor | note down basic lesson plans (remarks) for each lesson | have a structure to follow for each lesson |

### Use cases

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public ToStringBuilder add(String fieldName, Object fieldValue) {
*/
@Override
public String toString() {
return stringBuilder.toString() + OBJECT_SUFFIX;
return stringBuilder + OBJECT_SUFFIX;
}
}
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ public static String format(Person person) {
.append(person.getEmail())
.append("; Address: ")
.append(person.getAddress())
.append("; Tags: ");
person.getTags().forEach(builder::append);
.append("; Subject: ")
.append((person.getSubject()))
.append("; Lessons: ");
person.getLessons().forEach(builder::append);
return builder.toString();
}

Expand Down
13 changes: 9 additions & 4 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LESSON;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SUBJECT;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
Expand All @@ -26,14 +28,17 @@ public class AddCommand extends Command {
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ PREFIX_SUBJECT + "SUBJECT "
+ PREFIX_REMARK + "REMARK "
+ "[" + PREFIX_LESSON + "LESSON]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";
+ PREFIX_SUBJECT + "Maths "
+ PREFIX_REMARK + "He is a slow learner. "
+ PREFIX_LESSON + "Maths|23-05-2024|10:00|1";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
Expand Down
67 changes: 46 additions & 21 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LESSON;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;

import java.util.Collections;
Expand All @@ -23,12 +23,12 @@
import seedu.address.model.Model;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Lesson;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Remark;
import seedu.address.model.tag.Tag;

import seedu.address.model.person.Subject;

/**
* Edits the details of an existing person in the address book.
Expand All @@ -45,7 +45,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "[" + PREFIX_LESSON + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]";
Expand Down Expand Up @@ -101,10 +101,12 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail());
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());
Set<Lesson> updatedLessons = editPersonDescriptor.getLessons().orElse(personToEdit.getLessons());
Remark updatedRemark = personToEdit.getRemark();
Subject updatedSubject = editPersonDescriptor.getSubject().orElse(personToEdit.getSubject());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedRemark, updatedTags);
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress,
updatedSubject, updatedRemark, updatedLessons);
}

@Override
Expand Down Expand Up @@ -140,27 +142,39 @@ public static class EditPersonDescriptor {
private Phone phone;
private Email email;
private Address address;
private Set<Tag> tags;

private Set<Lesson> lessons;
private Subject subject;
private Remark remark;
public EditPersonDescriptor() {}

/**
* Copy constructor.
* A defensive copy of {@code tags} is used internally.
* A defensive copy of {@code lessons} is used internally.
*/
public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setName(toCopy.name);
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
setTags(toCopy.tags);
setLessons(toCopy.lessons);
setSubject(toCopy.subject);
setRemark(toCopy.remark);
setLessons(toCopy.lessons);
}

public void setRemark(Remark remark) {
this.remark = remark;
}

public Optional<Object> getRemark() {
return Optional.ofNullable(remark);
}

/**
* 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, subject, lessons, remark);
}

public void setName(Name name) {
Expand Down Expand Up @@ -196,20 +210,28 @@ public Optional<Address> getAddress() {
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
* Sets {@code lessons} to this object's {@code lessons}.
* A defensive copy of {@code lessons} is used internally.
*/
public void setTags(Set<Tag> tags) {
this.tags = (tags != null) ? new HashSet<>(tags) : null;
public void setLessons(Set<Lesson> lessons) {
this.lessons = (lessons != null) ? new HashSet<>(lessons) : null;
}

/**
* Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException}
* Returns an unmodifiable lesson set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
* Returns {@code Optional#empty()} if {@code tags} is null.
* Returns {@code Optional#empty()} if {@code lessons} is null.
*/
public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
public Optional<Set<Lesson>> getLessons() {
return (lessons != null) ? Optional.of(Collections.unmodifiableSet(lessons)) : Optional.empty();
}

public void setSubject(Subject subject) {
this.subject = subject;
}

public Optional<Subject> getSubject() {
return Optional.ofNullable(subject);
}

@Override
Expand All @@ -228,7 +250,8 @@ public boolean equals(Object other) {
&& Objects.equals(phone, otherEditPersonDescriptor.phone)
&& Objects.equals(email, otherEditPersonDescriptor.email)
&& Objects.equals(address, otherEditPersonDescriptor.address)
&& Objects.equals(tags, otherEditPersonDescriptor.tags);
&& Objects.equals(lessons, otherEditPersonDescriptor.lessons)
&& Objects.equals(subject, otherEditPersonDescriptor.subject);
}

@Override
Expand All @@ -238,7 +261,9 @@ public String toString() {
.add("phone", phone)
.add("email", email)
.add("address", address)
.add("tags", tags)
.add("subject", subject)
.add("remark", remark)
.add("lessons", lessons)
.toString();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/RemarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public CommandResult execute(Model model) throws CommandException {
}

Person personToEdit = lastShownList.get(index.getZeroBased());
Person editedPerson = new Person(
personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(),
personToEdit.getAddress(), remark, personToEdit.getTags());
Person editedPerson = new Person(personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(),
personToEdit.getAddress(), personToEdit.getSubject(),
personToEdit.getRemark(), personToEdit.getLessons());

model.setPerson(personToEdit, editedPerson);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
Expand Down
Loading
Loading