-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
54 lines (43 loc) · 1.57 KB
/
Copy pathMain.java
File metadata and controls
54 lines (43 loc) · 1.57 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
package com.adrianargint;
import java.io.*;
public class Main {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
House myHouse = new House();
BufferedReader input = new BufferedReader(new FileReader(new File("therm.in")));
FileWriter output = new FileWriter(new File("therm1.out"));
output.close();
//The first n lines were used in constructor of house, so skip them
for(int i = 0; i <= myHouse.getRoomNumber(); i++) {
String line = input.readLine();
}
String line;
while((line = input.readLine()) != null ){
String[] word = line.split(" ");
switch (word[0]){
case "OBSERVE":
myHouse.addObserve(word[1], Integer.parseInt(word[2]), Double.parseDouble(word[3]));
break;
case "OBSERVEH":
myHouse.addObserveH(word[1], Integer.parseInt(word[2]), Double.parseDouble(word[3]));
break;
case "TRIGGER":
myHouse.triggerHeat();
break;
case "TEMPERATURE":
myHouse.changeTemperature(Double.parseDouble(word[1]));
break;
case "LIST":
myHouse.list(word[1], Integer.parseInt(word[2]), Integer.parseInt(word[3]));
break;
default:
break;
}
}
input.close();
output.close();
}
}