-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHouse.java
More file actions
118 lines (100 loc) · 2.92 KB
/
House.java
File metadata and controls
118 lines (100 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* Adoga Haruna.
*/
import java.util.ArrayList; // to enable us use the array list in our program
public class House
{
private String address;
private String otherAddress;
ArrayList <ElectricalAppliance > appliance = new ArrayList <ElectricalAppliance> ();
/**
* House class constructor
*/
public House (String address){
this.address = address;
}
/**
* Method that adds appliance to the house
*/
public void addAppliance (ElectricalAppliance app)
{
app.setLocation(address);
appliance.add(app);
}
/**
* method to find appliance
*/
public ElectricalAppliance findAppliance(String elect)
{
for (ElectricalAppliance e : appliance) {
if (e.getName().contains(elect)) {
return e;
}
}
return null;
}
/**
* Method that removes an electrical appliance
*/
public void removeAppliance(ElectricalAppliance app)
{
appliance.remove(app);
}
/**
* Method that turns off all electrical appliance
*/
public void turnOffAll () {
for (ElectricalAppliance e : appliance )
{
e.setStatus(false);
}}
/**
* A method that turns on all Lights in the house
*/
public void turnOnAll () {
for (ElectricalAppliance e : appliance)
{
e.setStatus(true);
}}
/**
* Method turnOnApp
*
* @param app A parameter
*/
public void turnOnApp (String app) {
ElectricalAppliance electapp = findAppliance(app);
electapp.setStatus(true);
}
/**
* Method setTimeableLights
*
* @param currentTime A parameter
* @param startTime A parameter
* @param stopTime A parameter
*/
public void setTimeableLights (Time currentTime, Time startTime, Time stopTime)
{
for (int i = 0 ; i <appliance.size(); i ++)
{
if (appliance.get(i) instanceof TimeableLight)
{
TimeableLight timelight =(TimeableLight) appliance.get(i);
timelight.setTimes(startTime, stopTime);
timelight.setCurrentTime(currentTime);
appliance.set(i, timelight);
}
}
}
/**
* A toString method to display the house address and the details of the electrical appliance
*/
public String toString ()
{
String showappliance = "";
for (int i = 0; i < appliance.size() ; i ++)
{
showappliance = showappliance + appliance.get(i).toString();
}
return "the address of the house is : " + address + " the appliances in the house are : " + showappliance;
}
}