Rev 348 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*******************************************************************************
* main.cc
*
* Implementation of the main function.
*
* Copyright 2006, Ira W. Snyder (devel@irasnyder.com)
******************************************************************************/
#include <iostream>
#include <gtkmm/main.h>
#include "elevator_window.h"
int main (int argc, char *argv[])
{
int numFloors = -1;
int numElevators = -1;
std::cout << "Enter the number of floors [2-10]: ";
std::cin >> numFloors;
std::cout << "Enter the number of elevators [1-5]: ";
std::cin >> numElevators;
if (numFloors < 2 || numFloors > 10)
{
std::cerr << "Invalid number of floors" << std::endl;
return 1;
}
if (numElevators < 1 || numElevators > 5)
{
std::cerr << "Invalid number of elevators" << std::endl;
return 2;
}
// Set up the controller
Controller c(numFloors, numElevators);
// Start GTK
Gtk::Main kit (argc, argv);
// Create the window
Elevator_Window window (numFloors, numElevators);
// Set associations
window.set_controller (&c);
c.set_gui (&window);
// Start the backend
c.start_all_elevators ();
// Start the GUI
Gtk::Main::run (window);
return 0;
}