Subversion Repositories programming

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
340 ira 1
 
346 ira 2
#include <iostream>
340 ira 3
#include <gtkmm/main.h>
4
#include "elevator_window.h"
5
 
6
int main (int argc, char *argv[])
7
{
346 ira 8
    int numFloors = -1;
9
    int numElevators = -1;
10
 
11
    std::cout << "Enter the number of floors [2-10]: ";
12
    std::cin >> numFloors;
13
 
14
    std::cout << "Enter the number of elevators [1-5]: ";
15
    std::cin >> numElevators;
16
 
17
    if (numFloors < 2 || numFloors > 10)
18
    {
19
        std::cerr << "Invalid number of floors" << std::endl;
20
        return 1;
21
    }
22
 
23
    if (numElevators < 1 || numElevators > 5)
24
    {
25
        std::cerr << "Invalid number of elevators" << std::endl;
26
        return 2;
27
    }
28
 
340 ira 29
    // Set up the controller
30
    Controller c(10, 5);
31
 
32
    // Start GTK
33
    Gtk::Main kit (argc, argv);
34
 
35
    // Create the window
36
    Elevator_Window window;
37
 
38
    // Set associations
39
    window.set_controller (&c);
40
    c.set_gui (&window);
41
 
42
    // Start the backend
43
    c.start_all_elevators ();
44
 
45
    // Start the GUI
46
    Gtk::Main::run (window);
47
 
48
    return 0;
49
}
50