Skip to content

Commit

Permalink
Merge pull request #1 from jessen11/tutorial-removing-field
Browse files Browse the repository at this point in the history
Tutorial removing field
  • Loading branch information
jessen11 authored Feb 28, 2021
2 parents 8d32821 + 87eecd0 commit 87c0387
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 145 deletions.
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
[![CI Status](https://github.com/se-edu/addressbook-level3/workflows/Java%20CI/badge.svg)](https://github.com/se-edu/addressbook-level3/actions)

# Dictionote
![CI Status](https://github.com/se-edu/addressbook-level3/workflows/Java%20CI/badge.svg)](https://github.com/se-edu/addressbook-level3/actions)
![Ui](docs/images/Ui.png)

* This is **a sample project for Software Engineering (SE) students**.<br>
Example usages:
* as a starting point of a course project (as opposed to writing everything from scratch)
* as a case study
* The project simulates an ongoing software project for a desktop application (called _AddressBook_) used for managing contact details.
* It is **written in OOP fashion**. It provides a **reasonably well-written** code base **bigger** (around 6 KLoC) than what students usually write in beginner-level SE modules, without being overwhelmingly big.
* It comes with a **reasonable level of user and developer documentation**.
* It is named `AddressBook Level 3` (`AB3` for short) because it was initially created as a part of a series of `AddressBook` projects (`Level 1`, `Level 2`, `Level 3` ...).
* For the detailed documentation of this project, see the **[Address Book Product Website](https://se-education.org/addressbook-level3)**.
* This project is a **part of the se-education.org** initiative. If you would like to contribute code to this project, see [se-education.org](https://se-education.org#https://se-education.org/#contributing) for more info.
* This is a desktop Dictionote application. The image above shows the sample UI of Dictionote.

## Site Map

* [User Guide](https://github.com/AY2021S2-CS2103T-W13-1/tp/blob/master/docs/UserGuide.md)
* [Developer Guide](https://github.com/AY2021S2-CS2103T-W13-1/tp/blob/master/docs/DeveloperGuide.md)
* [About us](https://github.com/AY2021S2-CS2103T-W13-1/tp/blob/master/docs/AboutUs.md)


## Acknowledgements


* This application was built upon the AddressBook-Level3 project created by [SE-EDU initiative](https://se-education.org/)

Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 3 additions & 13 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand Down Expand Up @@ -96,10 +95,9 @@ 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());
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

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

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

public EditPersonDescriptor() {}
Expand All @@ -141,15 +138,14 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setName(toCopy.name);
setPhone(toCopy.phone);
setEmail(toCopy.email);
setAddress(toCopy.address);
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, tags);
}

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

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

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


/**
* Sets {@code tags} to this object's {@code tags}.
Expand Down Expand Up @@ -219,7 +210,6 @@ public boolean equals(Object other) {
return getName().equals(e.getName())
&& getPhone().equals(e.getPhone())
&& getEmail().equals(e.getEmail())
&& getAddress().equals(e.getAddress())
&& getTags().equals(e.getTags());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand Down Expand Up @@ -41,10 +40,9 @@ public AddCommand parse(String args) throws ParseException {
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));

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

return new AddCommand(person);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ 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()));
}

parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);

if (!editPersonDescriptor.isAnyFieldEdited()) {
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
Expand Down Expand Up @@ -71,14 +70,6 @@ public static Phone parsePhone(String phone) throws ParseException {
*
* @throws ParseException if the given {@code address} 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);
}
return new Address(trimmedAddress);
}

/**
* Parses a {@code String email} into an {@code Email}.
Expand Down
57 changes: 0 additions & 57 deletions src/main/java/seedu/address/model/person/Address.java

This file was deleted.

16 changes: 4 additions & 12 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ public class Person {
private final Email email;

// Data fields
private final Address address;
private final Set<Tag> tags = new HashSet<>();

/**
* Every field must be present and not null.
*/
public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tags) {
requireAllNonNull(name, phone, email, address, tags);
public Person(Name name, Phone phone, Email email, Set<Tag> tags) {
requireAllNonNull(name, phone, email, tags);
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
this.tags.addAll(tags);
}

Expand All @@ -48,9 +46,6 @@ public Email getEmail() {
return email;
}

public Address getAddress() {
return address;
}

/**
* Returns an immutable tag set, which throws {@code UnsupportedOperationException}
Expand Down Expand Up @@ -91,14 +86,13 @@ public boolean equals(Object other) {
return otherPerson.getName().equals(getName())
&& otherPerson.getPhone().equals(getPhone())
&& otherPerson.getEmail().equals(getEmail())
&& otherPerson.getAddress().equals(getAddress())
&& otherPerson.getTags().equals(getTags());
}

@Override
public int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(name, phone, email, address, tags);
return Objects.hash(name, phone, email, tags);
}

@Override
Expand All @@ -108,9 +102,7 @@ public String toString() {
.append("; Phone: ")
.append(getPhone())
.append("; Email: ")
.append(getEmail())
.append("; Address: ")
.append(getAddress());
.append(getEmail());

Set<Tag> tags = getTags();
if (!tags.isEmpty()) {
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -20,22 +19,16 @@ public class SampleDataUtil {
public static Person[] getSamplePersons() {
return new Person[] {
new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("[email protected]"),
new Address("Blk 30 Geylang Street 29, #06-40"),
getTagSet("friends")),
new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("[email protected]"),
new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"),
getTagSet("colleagues", "friends")),
new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("[email protected]"),
new Address("Blk 11 Ang Mo Kio Street 74, #11-04"),
getTagSet("neighbours")),
new Person(new Name("David Li"), new Phone("91031282"), new Email("[email protected]"),
new Address("Blk 436 Serangoon Gardens Street 26, #16-43"),
getTagSet("family")),
new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("[email protected]"),
new Address("Blk 47 Tampines Street 20, #17-35"),
getTagSet("classmates")),
new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("[email protected]"),
new Address("Blk 45 Aljunied Street 85, #11-31"),
getTagSet("colleagues"))
};
}
Expand Down
18 changes: 2 additions & 16 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -27,23 +26,18 @@ class JsonAdaptedPerson {
private final String name;
private final String phone;
private final String email;
private final String address;
private final List<JsonAdaptedTag> tagged = new ArrayList<>();

/**
* Constructs a {@code JsonAdaptedPerson} with the given person details.
*/
@JsonCreator
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone,
@JsonProperty("email") String email, @JsonProperty("address") String address,
@JsonProperty("email") String email,
@JsonProperty("tagged") List<JsonAdaptedTag> tagged) {
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
if (tagged != null) {
this.tagged.addAll(tagged);
}
}

/**
Expand All @@ -53,7 +47,6 @@ public JsonAdaptedPerson(Person source) {
name = source.getName().fullName;
phone = source.getPhone().value;
email = source.getEmail().value;
address = source.getAddress().value;
tagged.addAll(source.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList()));
Expand Down Expand Up @@ -94,16 +87,9 @@ public Person toModelType() throws IllegalValueException {
}
final Email modelEmail = new Email(email);

if (address == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()));
}
if (!Address.isValidAddress(address)) {
throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS);
}
final Address modelAddress = new Address(address);

final Set<Tag> modelTags = new HashSet<>(personTags);
return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags);
return new Person(modelName, modelPhone, modelEmail, modelTags);
}

}
3 changes: 0 additions & 3 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label phone;
@FXML
private Label address;
@FXML
private Label email;
@FXML
private FlowPane tags;
Expand All @@ -50,7 +48,6 @@ public PersonCard(Person person, int displayedIndex) {
id.setText(displayedIndex + ". ");
name.setText(person.getName().fullName);
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
</HBox>
<FlowPane fx:id="tags" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
</VBox>
</GridPane>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
"name": "Valid Person",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
}, {
"name": "Person With Invalid Phone Field",
"phone": "948asdf2424",
"email": "[email protected]",
"address": "4th street"
} ]
}
Loading

0 comments on commit 87c0387

Please sign in to comment.