-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.java
More file actions
44 lines (38 loc) · 960 Bytes
/
Copy pathApplication.java
File metadata and controls
44 lines (38 loc) · 960 Bytes
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
package house;
public class Application {
private House[] hotels;
private House aNewOne;
private int numOfHotels = 1;
public Application() {
hotels = new House[numOfHotels];
for (int i = 0; i < numOfHotels; i++) {
int left = (20 * i^2) + i*80 + 200;
int top = 300;
int width = 400;
int height = 120 + (36 * (i+1));
hotels[i] = new House(left, top, width, height);
}
changeFirstHotel();
}
private void changeFirstHotel() {
removeAWindow();
}
public void removeAWindow() {
Window aDetachedWindow = hotels[0].detachWindow();
hotels[0] = null;
System.out.println(aDetachedWindow.getInfo());
System.out.println("Now attach window to new house: ");
aNewOne = new House(600, 400, 100, 100);
aNewOne.attachAWindow(aDetachedWindow);
}
public void draw() {
for (int i = 0; i < numOfHotels; i++) {
if ( hotels[i] != null ) {
hotels[i].draw();
}
}
if ( aNewOne != null) {
aNewOne.draw();
}
}
}