diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 847deb8..a64b376 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
index 79b47e9..9fc555b 100644
--- a/.gradle/buildOutputCleanup/cache.properties
+++ b/.gradle/buildOutputCleanup/cache.properties
@@ -1,2 +1,2 @@
-#Wed Feb 19 20:29:41 CET 2020
-gradle.version=6.0.1
+#Thu Feb 20 16:16:13 CET 2020
+gradle.version=6.2
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cf95fe9..8f27022 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,7 @@
-
+
\ No newline at end of file
diff --git a/backend.iml b/backend.iml
new file mode 100644
index 0000000..1eae0df
--- /dev/null
+++ b/backend.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java
index 12575d0..667b587 100644
--- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java
+++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java
@@ -2,6 +2,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import com.google.gson.annotations.Expose;
+import java.util.concurrent.atomic.AtomicLong;
+
//Rules
/**
@@ -17,7 +19,7 @@ public abstract class Device {
OUTPUT
}
- private static long nextId = 1;
+ private static AtomicLong nextId = new AtomicLong(1);
/**
* Device identifier
@@ -49,10 +51,7 @@ public abstract class Device {
}
public Device(String kind, FlowType flowType) {
- synchronized (Device.class) {
- this.id = nextId;
- nextId++;
- }
+ this.id = nextId.getAndIncrement();
this.kind = kind;
this.flowType = flowType;
this.name = kind + " " + this.id;
diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java
index 988d4b5..1fb140c 100644
--- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java
+++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableLight.java
@@ -14,6 +14,9 @@ public class DimmableLight extends Light implements DimmableOutput {
@Override
public void dimTo(int level) {
+ if(level<0 || level>100){
+ throw new java.lang.Error("The intensity level can't go below 0 or above 100");
+ }
intensity = level;
}
}
diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java
new file mode 100644
index 0000000..f073e43
--- /dev/null
+++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java
@@ -0,0 +1,27 @@
+package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
+import java.util.*;
+
+public class Room {
+ private ArrayList devices;
+
+ //Constructor
+ public Room(){
+ this.devices=new ArrayList();
+ }
+
+ //add a device to the list
+ public void addDevice(Device device){
+ if(!this.devices.contains(device)){
+ this.devices.add(device);
+ }
+ }
+
+ //remove a certain device from the Room
+ public void removeDevice(Device device){
+ int a=this.devices.indexOf(device);
+ if(a!=-1) {
+ this.devices.remove(a);
+ }
+ }
+
+}
diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/house.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/house.java
new file mode 100644
index 0000000..49c17fa
--- /dev/null
+++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/house.java
@@ -0,0 +1,29 @@
+package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
+
+import java.util.ArrayList;
+
+public class house {
+ //a list of the rooms present in the house
+ private ArrayList rooms;
+
+ //Constructor
+ public house(){
+ this.rooms=new ArrayList();
+ }
+
+ //this method add a Room to the house
+ public void addRoom(Room room){
+ if(!this.rooms.contains(room)) {
+ this.rooms.add(room);
+ }
+ }
+
+ //this method removes the given room if it is present in the house
+ public void remove(Room room){
+ int a=this.rooms.indexOf(room);
+ if(a!=-1) {
+ this.rooms.remove(a);
+ }
+ }
+
+}