Skip to content
Snippets Groups Projects
Commit cf644c27 authored by Gabriel Copat's avatar Gabriel Copat
Browse files

Added new Trail.java method to find trail image path, otherwise use a default image.

Also added default image to images/trails folder
parent 6acff029
No related branches found
No related tags found
1 merge request!11Resolve "As a user, I want to see all trails across a town and seamlessly move between them."
......@@ -2,6 +2,7 @@ package Team5.SmartTowns.trails;
import lombok.Data;
import java.io.File;
import java.util.List;
@Data
......@@ -10,7 +11,8 @@ public class Trail {
new Trail(1,"Trail1", "This is trail one"),
new Trail(2,"Trail2", "This is trail two"),
new Trail(3,"Trail3", "This is trail three"),
new Trail(4,"Trail4", "This is trail four")
new Trail(4,"Trail4", "This is trail four"),
new Trail(5,"Trail5", "This is trail five, it has no image")
);
int id;
String name;
......@@ -23,6 +25,15 @@ public class Trail {
this.id = id;
this.name = name;
this.description = description;
imgPath = "images/trails/trail" + id + ".jpg";
imgPath = findImagePath();
}
private String findImagePath(){
/* Finds the image in the Path folder, if image is not found assigns default image */
String imgPath = "images/trails/trail" + id + ".jpg";
String notFoundPath = "images/trails/trailNotFound.jpg";
File imgFile = new File("src/main/resources/static/" + imgPath);
return imgFile.exists() ? imgPath : notFoundPath;
}
}
src/main/resources/static/images/trails/trailNotFound.jpg

73.8 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment