diff options
author | Santo Cariotti <sancn@live.com> | 2017-04-26 16:37:39 +0200 |
---|---|---|
committer | Santo Cariotti <sancn@live.com> | 2017-04-26 16:37:39 +0200 |
commit | 483d63fa7249ad8d6020680c48c3cf6df35010b3 (patch) | |
tree | 2f8649e3ae6b42ace5011246285c9c450f004222 /ascensore.cc | |
parent | 6c957dc4e01aee6ce9cae3c8342d04b0fd9ca9c4 (diff) |
Moved all C++ files into CPP folder
Diffstat (limited to 'ascensore.cc')
-rw-r--r-- | ascensore.cc | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/ascensore.cc b/ascensore.cc deleted file mode 100644 index 8e69964..0000000 --- a/ascensore.cc +++ /dev/null @@ -1,90 +0,0 @@ -#include <iostream> -#include <stdlib.h> -#include <string> -#include <unistd.h> - -class Ascensore -{ -private: - unsigned short int floor; - bool doors; - unsigned short int maxFloor; -public: - Ascensore(unsigned short int plan = 0) {floor = plan; maxFloor = 5;} - void Up(void); - void Down(void); - void Doors(void); - void getFloor(void); -}; - -void _clear(void); - -using namespace std; - -int main(void) -{ - char choose; - Ascensore *ascensore = new Ascensore(); - do { - ascensore->getFloor(); - cin >> choose; - choose = tolower(choose); - if(choose == 'u' || choose == 'd') ascensore->Doors(); - sleep(2); - switch(choose) - { - case 'u' : ascensore->Up(); break; - case 'd' : ascensore->Down(); break; - case 'e' : break; - } - _clear(); - if(choose == 'u' || choose == 'd') ascensore->Doors(); - } while(choose != 'e'); - - cout << "SEI USCITO DALL'ASCENSORE CON SUCCESSO!"; - - return 0; -} - -void _clear(void) -{ - #ifdef OS_WINDOWS - system("CLS"); - #else - system("clear"); - #endif -} - -void Ascensore::getFloor(void) -{ - if(floor == maxFloor) cout << "Sei arrivato all'ultimo piano" << endl; - if(floor == 0) cout << "Non puoi scendere più di così" << endl; - cout << "SEI ATTUALMENTE AL PIANO " << floor << endl; - cout << "\nQUALE AZIONE SI VUOLE COMPIERE?" << endl; - cout << "U - salire" << endl; - cout << "D - scendere" << endl; - cout << "E - Uscire" << endl; - cout << "> "; -} - -void Ascensore::Up(void) -{ - if(floor < maxFloor) floor+=1; -} - -void Ascensore::Down(void) -{ - if(floor > 0) floor-=1; -} - -void Ascensore::Doors(void) -{ - if(doors == true) - { - cout << "> APERTURA PORTE" << endl; - doors = false; - } else { - cout << "> CHIUSURA PORTE..." << endl; - doors = true; - } -} |