OOP2

MainWindow.java

1
/**
2
 * Main window for the hostel program.
3
 * This class creates some sort of "main menu screen". It displays a concise set
4
 * of buttons, that allow the user to reach all parts of the program's GUI.
5
 * To be called as soon as the program is started (Essentially from the Main
6
 * class).
7
 * @author Maarten Vangeneugden - 1438256
8
 */
9
public class MainWindow {
10
11
	private ReservationController reservationController;
12
	private RoomController roomController;
13
	private WalkController walkController;
14
	
15
	public MainWindow(ReservationController reservationController, RoomController roomController, WalkController walkController) {
16
		this.reservationController = reservationController;
17
		this.roomController = roomController;
18
		this.walkController = walkController;
19
20
		Window window = new Window("Main menu");
21
		window.createButton("New reservation", "", "addReservation", this);
22
		window.createButton("New walking reservation", "", "addWalkReservation", this);
23
		window.createButton("Search screen", "", "openSearchView", this);
24
		window.createButton("Walks Search screen", "", "openWalkSearchView", this);
25
	}
26
27
	public void openSearchView() {
28
		SearchView sv = new SearchView(this.reservationController, this.roomController);
29
	}
30
	
31
	public void addReservation() {
32
		Reservation reservation = new Reservation();
33
		ReservationView rv = new ReservationView(reservation, this.reservationController, this.roomController);
34
	}
35
36
	public void openWalkSearchView() {
37
		WalkSearchView wsv = new WalkSearchView(this.reservationController, this.walkController);
38
	}
39
40
	/**
41
	 * Create a Walk Reservation creation screen.
42
	 * @pre walkController must have at least one Walk stored in it.
43
	 * @throws IndexArrayOutOfBoundsException is walkController has no Walks in
44
	 * it.
45
	 */
46
	public void addWalkReservation() {
47
		WalkReservation walkReservation = new WalkReservation();
48
		walkReservation.setWalk(this.walkController.getWalks().toArray(new Walk[1])[0]);
49
		WalkView wv = new WalkView(walkReservation, this.reservationController, this.walkController);
50
	}
51
}
52