Skip to content

Commit

Permalink
Fix Bugs and User able to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqing-nic committed Oct 28, 2018
1 parent d77d7e7 commit 2284bf7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 18 additions & 4 deletions src/main/java/seedu/address/model/person/Photo.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,20 @@ private void makePhoto(String filePath, String newPhoto) {

logger.info("makephoto");
logger.info(filePath);
//get image from source
String immm = System.getProperty("user.home") + "/Documents/cs2103/debt-tracker/docs/images/weiqing-nic.png";
if (filePath == "delete") {
filePath = "images/default_person.png";
} else {
//get image from source
String immm = System.getProperty("user.home") + "/Documents/cs2103/debt-tracker/docs/images/weiqing-nic.png";
//System.out.println(immm);
filePath = "/" + filePath;
}
//System.out.println(filePath);
File getImage = new File(filePath);
//File getImage = new File(immm);



//create file object
String fileName = FOLDER + "/" + newPhoto + ".png";
File pictureFinal = new File(fileName);
Expand All @@ -90,9 +98,15 @@ private void makePhoto(String filePath, String newPhoto) {
}

try {
Files.copy(getImage.toPath(), pictureFinal.toPath(), REPLACE_EXISTING);
this.photoPath = pictureFinal.toPath().toString();
if (filePath == "delete"){
this.photoPath = "images/default_person.png";
} else {
Files.copy(getImage.toPath(), pictureFinal.toPath(), REPLACE_EXISTING);
this.photoPath = pictureFinal.toPath().toString();
}
} catch (IOException e) {
this.photoPath = "images/default_person.png";

e.printStackTrace();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ public Photo getPhoto() {
return photo;
}

public void deletePhoto() {
this.photo = new Photo();
}

public void setPhoto(String photoPath) throws IllegalValueException {
Photo previousPhoto = this.photo;
try {
Expand Down

0 comments on commit 2284bf7

Please sign in to comment.