From aba378712ee68560301de4737aa34c4d4dcfadea Mon Sep 17 00:00:00 2001 From: wang Date: Mon, 15 Apr 2024 21:07:02 +0800 Subject: [PATCH] Delete ImagePath from person constructor --- .../seedu/address/model/person/Person.java | 26 ------------------- .../address/storage/JsonAdaptedPerson.java | 21 ++------------- .../java/seedu/address/ui/PersonCard.java | 2 +- 3 files changed, 3 insertions(+), 46 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index d43d74b94c0..2a347293c20 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -24,7 +24,6 @@ public class Person { private final Address address; private final Set tags = new HashSet<>(); - private ImagePath image; private Rating rating; /** @@ -37,30 +36,9 @@ public Person(Name name, Phone phone, Email email, Address address, Set 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 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; } @@ -89,10 +67,6 @@ public Set 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. diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index 3e06e6b3845..5312f61d8bb 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -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 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 tags) { + @JsonProperty("tags") List tags) { this.name = name; this.phone = phone; this.email = email; @@ -80,7 +64,6 @@ public JsonAdaptedPerson(Person source) { tags.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); - image = source.getImage().getFilePath().toString(); } /** @@ -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); } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 5b8fd9a2e2e..6e4b7d39df4 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -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);