Skip to content

Commit

Permalink
AC & Security System classes added
Browse files Browse the repository at this point in the history
  • Loading branch information
danielharbor committed Feb 24, 2015
1 parent 2d43702 commit 84dc718
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
22 changes: 22 additions & 0 deletions AC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.List;
import java.util.ArrayList;

public class AC extends Electronic {

public AC(String name, Room room, boolean state) {
super(name, room, state);
}

@Override
public List<String> provideDetails() {
List<String> res = new ArrayList<>();
res.add("Name: " + this.getName() + "\n");
res.add("Room: " + this.getRoom().getName() + "\nCurrent State: ");
if(getState())
res.add("ON");
else
res.add("OFF");
return res;
}

}
2 changes: 1 addition & 1 deletion MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public MainFrame(String title) {

//Items list
list = new JList<Thing>(listSelectionModel);
list.setVisibleRowCount(10);
list.setVisibleRowCount(5);
scroller = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
list.setFixedCellHeight(30);
list.setFixedCellWidth(150);
Expand Down
22 changes: 22 additions & 0 deletions SecuritySystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.List;
import java.util.ArrayList;

public class SecuritySystem extends Electronic {

public SecuritySystem(String name, Room room, boolean state) {
super(name, room, state);
}

@Override
public List<String> provideDetails() {
List<String> res = new ArrayList<>();
res.add("Name: " + this.getName() + "\n");
res.add("Room: " + this.getRoom().getName() + "\nCurrent State: ");
if(getState())
res.add("ON");
else
res.add("OFF");
return res;
}

}
4 changes: 4 additions & 0 deletions Simulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ public class Simulator {
Person john = new Person("John", "M", room2);
Microwave sonyMicrowave = new Microwave("Sony Microwave", room1, true);
Microwave samsungMicrowave = new Microwave("Samsung Microwave", room1, false);
SecuritySystem comcastSec = new SecuritySystem("Comcast Security System", room2, true);
AC panasonicAC = new AC("Panasonic AC", room2, true);
thingsInSimulation.add(jane);
thingsInSimulation.add(john);
thingsInSimulation.add(room1);
thingsInSimulation.add(room2);
thingsInSimulation.add(sonyMicrowave);
thingsInSimulation.add(samsungMicrowave);
thingsInSimulation.add(panasonicAC);
thingsInSimulation.add(comcastSec);
}

public static Set<Thing> getThings() {
Expand Down

0 comments on commit 84dc718

Please sign in to comment.