diff --git a/Diagrams/Class Diagram Delivery 3.png b/Diagrams/Class Diagram Delivery 3.png new file mode 100644 index 0000000..11292ce Binary files /dev/null and b/Diagrams/Class Diagram Delivery 3.png differ diff --git a/Diagrams/Package model.png b/Diagrams/Package model.png new file mode 100644 index 0000000..01f232d Binary files /dev/null and b/Diagrams/Package model.png differ diff --git a/model.uml b/model.uml new file mode 100644 index 0000000..c2685bf --- /dev/null +++ b/model.uml @@ -0,0 +1,39 @@ + + + JAVA + smarthomesimulator.model + + smarthomesimulator.model.SHP + smarthomesimulator.model.Zone + smarthomesimulator.model.Door + smarthomesimulator.model.Profile.Role + smarthomesimulator.model.Light + smarthomesimulator.model.RoomTest + smarthomesimulator.model.Simulator + smarthomesimulator.model.Profile + smarthomesimulator.model.ConsoleOutput + smarthomesimulator.model.Room + smarthomesimulator.model.Window + + + + + + + + + + + smarthomesimulator.model.SHP + + + Inner Classes + Properties + Methods + Constructors + Fields + + All + private + + diff --git a/smart-home-simulator/src/main/java/smarthomesimulator/DashboardController.java b/smart-home-simulator/src/main/java/smarthomesimulator/DashboardController.java index 5bd6838..13ba171 100644 --- a/smart-home-simulator/src/main/java/smarthomesimulator/DashboardController.java +++ b/smart-home-simulator/src/main/java/smarthomesimulator/DashboardController.java @@ -1,21 +1,14 @@ package smarthomesimulator; import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.ModelMap; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import smarthomesimulator.model.*; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import java.util.Map; import java.util.ArrayList; @@ -422,6 +415,4 @@ public Simulator getTemps(){ Simulator sim = simulatorMap.get(0); return sim; } - - } diff --git a/smart-home-simulator/src/main/java/smarthomesimulator/SmartHomeController.java b/smart-home-simulator/src/main/java/smarthomesimulator/SmartHomeController.java index 2ce1d4a..7391c6d 100644 --- a/smart-home-simulator/src/main/java/smarthomesimulator/SmartHomeController.java +++ b/smart-home-simulator/src/main/java/smarthomesimulator/SmartHomeController.java @@ -28,8 +28,8 @@ public ModelAndView showForm() { } @RequestMapping(value = "/simulator", method = {RequestMethod.GET, RequestMethod.POST}) - public String submit(@Validated @ModelAttribute("simulator") Simulator simulator, @Validated @ModelAttribute("profile") Profile profile, @Validated @ModelAttribute("shp") SHP shp, - BindingResult result, ModelMap model, @RequestParam("file") String fileName) { + public String simulator(@Validated @ModelAttribute("simulator") Simulator simulator, @Validated @ModelAttribute("profile") Profile profile, @Validated @ModelAttribute("shp") SHP shp, + BindingResult result, ModelMap model, @RequestParam("file") String fileName) { if (result.hasErrors()) { return "error"; } diff --git a/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observable.java b/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observable.java index 2d35930..0fae63b 100644 --- a/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observable.java +++ b/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observable.java @@ -1,8 +1,5 @@ package smarthomesimulator.interfaces; public interface Observable { - - public void attachObserver(Observer o); - public void detachObserver(Observer o); - public void notifyObserver(Observable observable); + void notifyObserver(Observable observable); } diff --git a/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observer.java b/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observer.java index 60d4e76..074bb0d 100644 --- a/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observer.java +++ b/smart-home-simulator/src/main/java/smarthomesimulator/interfaces/Observer.java @@ -1,5 +1,5 @@ package smarthomesimulator.interfaces; public interface Observer { - public void update(Observable o); + void update(Observable o); } diff --git a/smart-home-simulator/src/main/java/smarthomesimulator/layout/ParseLayout.java b/smart-home-simulator/src/main/java/smarthomesimulator/layout/ParseLayout.java index 2e3e279..7006cff 100644 --- a/smart-home-simulator/src/main/java/smarthomesimulator/layout/ParseLayout.java +++ b/smart-home-simulator/src/main/java/smarthomesimulator/layout/ParseLayout.java @@ -26,31 +26,35 @@ public static void parse(String fileName) throws IOException { Pattern patternLights = Pattern.compile("Lights:(.*?);"); Matcher matcherLights = patternLights.matcher(line); - if (matcherRoomName.find()) { - int numOfDoors = 0; - int numOfWindows = 0; - int numOfLights = 0; + matchRooms(matcherRoomName, matcherDoors, matcherWindows, matcherLights); + } + br.close(); + } - String roomName = matcherRoomName.group(1); + private static void matchRooms(Matcher matcherRoomName, Matcher matcherDoors, Matcher matcherWindows, Matcher matcherLights) { + if (matcherRoomName.find()) { + int numOfDoors = 0; + int numOfWindows = 0; + int numOfLights = 0; - if (matcherDoors.find()) { - numOfDoors = (Integer.parseInt(matcherDoors.group(1))); - } + String roomName = matcherRoomName.group(1); - if (matcherWindows.find()) { - numOfWindows = (Integer.parseInt(matcherWindows.group(1))); - } + if (matcherDoors.find()) { + numOfDoors = (Integer.parseInt(matcherDoors.group(1))); + } - if (matcherLights.find()) { - numOfLights = ((Integer.parseInt(matcherLights.group(1)))); - } - - Room room = new Room(roomName, numOfDoors, numOfWindows,numOfLights); + if (matcherWindows.find()) { + numOfWindows = (Integer.parseInt(matcherWindows.group(1))); + } - Simulator.roomsOfHouse.add(room); + if (matcherLights.find()) { + numOfLights = ((Integer.parseInt(matcherLights.group(1)))); } + + Room room = new Room(roomName, numOfDoors, numOfWindows,numOfLights); + Simulator.roomsOfHouse.add(room); } - br.close(); } + } diff --git a/smart-home-simulator/src/main/resources/static/js/shhTab.js b/smart-home-simulator/src/main/resources/static/js/shhTab.js deleted file mode 100644 index 139597f..0000000 --- a/smart-home-simulator/src/main/resources/static/js/shhTab.js +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/smart-home-simulator/src/test/java/smarthomesimulator/model/RoomTest.java b/smart-home-simulator/src/test/java/smarthomesimulator/model/RoomTest.java index 0f6fcb4..2e617b5 100644 --- a/smart-home-simulator/src/test/java/smarthomesimulator/model/RoomTest.java +++ b/smart-home-simulator/src/test/java/smarthomesimulator/model/RoomTest.java @@ -41,13 +41,13 @@ void openCloseWindowsTest() { } @Test - void getBlockedDoors() { + void blockingDoorsTest() { room.setBlockedDoors(1); Assertions.assertEquals(room.getBlockedDoors(), 1); } @Test - void getBlockedWindows() { + void blockingWindowsTest() { room.setBlockedWindows(1); Assertions.assertEquals(room.getBlockedWindows(), 1); }