Skip to content

Commit

Permalink
Merge pull request #217 from ChrysanthemumT/testing
Browse files Browse the repository at this point in the history
Delete ImagePath from person constructor
  • Loading branch information
cyqjoseph authored Apr 15, 2024
2 parents 1d8c7fe + aba3787 commit cf264c6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 46 deletions.
26 changes: 0 additions & 26 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class Person {
private final Address address;

private final Set<Tag> tags = new HashSet<>();
private ImagePath image;
private Rating rating;

/**
Expand All @@ -37,30 +36,9 @@ public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tag
this.email = email;
this.address = address;
this.tags.addAll(tags);
this.image = new ImagePath();
}


/**
* Constructs a Person object with the specified attributes.
*
* @param name The name of the person.
* @param phone The phone number of the person.
* @param email The email address of the person.
* @param address The address of the person.
* @param tags The set of tags associated with the person.
* @param image The image path of the person.
*/
public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tags, ImagePath image) {
requireAllNonNull(name, phone, email, address, tags);
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
this.tags.addAll(tags);
this.image = image;
}

public Name getName() {
return name;
}
Expand Down Expand Up @@ -89,10 +67,6 @@ public Set<Tag> getTags() {
return Collections.unmodifiableSet(tags);
}

public ImagePath getImage() {
return this.image;
}

/**
* Returns true if both persons have the same name.
* This defines a weaker notion of equality between two persons.
Expand Down
21 changes: 2 additions & 19 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,7 @@ class JsonAdaptedPerson {
@JsonCreator
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone,
@JsonProperty("email") String email, @JsonProperty("address") String address,
@JsonProperty("tags") List<JsonAdaptedTag> tags, @JsonProperty("image") String image) {
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
if (tags != null) {
this.tags.addAll(tags);
}
this.image = image;
}

/**
* Constructs a {@code JsonAdaptedPerson} with the given person details without image.
*/
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone,
@JsonProperty("email") String email, @JsonProperty("address") String address,
@JsonProperty("tags") List<JsonAdaptedTag> tags) {
@JsonProperty("tags") List<JsonAdaptedTag> tags) {
this.name = name;
this.phone = phone;
this.email = email;
Expand All @@ -80,7 +64,6 @@ public JsonAdaptedPerson(Person source) {
tags.addAll(source.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList()));
image = source.getImage().getFilePath().toString();
}

/**
Expand Down Expand Up @@ -121,7 +104,7 @@ public Person toModelType() throws IllegalValueException {

if (image != null) {
final ImagePath imagePath = new ImagePath(Paths.get(image));
return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags, imagePath);
return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags);
} else {
return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public PersonCard(Person person, int displayedIndex) {
final Circle clip = new Circle(45, 45, 39);
displayPicture.setClip(clip);
displayPicture.setImage(new Image(Objects.requireNonNull(this.getClass()
.getResourceAsStream(person.getImage().getStringPath()))));
.getResourceAsStream("/images/default_image.png"))));
phone.setText(person.getPhone() == null ? "" : person.getPhone().value);
address.setText(person.getAddress() == null ? "" : person.getAddress().value);
email.setText(person.getEmail() == null ? "" : person.getEmail().value);
Expand Down

0 comments on commit cf264c6

Please sign in to comment.