small changes

This commit is contained in:
Jacob Salvi 2020-02-21 15:36:04 +01:00
parent 346d305950
commit 7d582dbb47
8 changed files with 78 additions and 8 deletions

View file

@ -1,2 +1,2 @@
#Wed Feb 19 20:29:41 CET 2020 #Thu Feb 20 16:16:13 CET 2020
gradle.version=6.0.1 gradle.version=6.2

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" project-jdk-name="12.0.1" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

12
backend.iml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -2,6 +2,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import java.util.concurrent.atomic.AtomicLong;
//Rules //Rules
/** /**
@ -17,7 +19,7 @@ public abstract class Device {
OUTPUT OUTPUT
} }
private static long nextId = 1; private static AtomicLong nextId = new AtomicLong(1);
/** /**
* Device identifier * Device identifier
@ -49,10 +51,7 @@ public abstract class Device {
} }
public Device(String kind, FlowType flowType) { public Device(String kind, FlowType flowType) {
synchronized (Device.class) { this.id = nextId.getAndIncrement();
this.id = nextId;
nextId++;
}
this.kind = kind; this.kind = kind;
this.flowType = flowType; this.flowType = flowType;
this.name = kind + " " + this.id; this.name = kind + " " + this.id;

View file

@ -14,6 +14,9 @@ public class DimmableLight extends Light implements DimmableOutput {
@Override @Override
public void dimTo(int level) { 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; intensity = level;
} }
} }

View file

@ -0,0 +1,27 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import java.util.*;
public class Room {
private ArrayList<Device> devices;
//Constructor
public Room(){
this.devices=new ArrayList<Device>();
}
//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);
}
}
}

View file

@ -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<Room> rooms;
//Constructor
public house(){
this.rooms=new ArrayList<Room>();
}
//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);
}
}
}