|
| 1 | +#include <iostream.h> |
| 2 | +#include <stdio.h> |
| 3 | +#include <stdlib.h> |
| 4 | +#include <conio.h> |
| 5 | +#include "graphic.cpp" |
| 6 | +#include "define.cpp" |
| 7 | + |
| 8 | +int main() |
| 9 | +{ |
| 10 | + BANKER banker; |
| 11 | + |
| 12 | + if (!banker.isSAFESTATE()) |
| 13 | + { |
| 14 | + banker.dealloc(); |
| 15 | + exit(1); |
| 16 | + } |
| 17 | + |
| 18 | + char choice; |
| 19 | + do |
| 20 | + { |
| 21 | + clrscr(); |
| 22 | + title(); |
| 23 | + box(1, 1, 24, 80); |
| 24 | + gotoxy(20, 6); |
| 25 | + cout << "\t1. Modify DataSheet"; |
| 26 | + gotoxy(20, 8); |
| 27 | + cout << "\t2. Current SnapShot"; |
| 28 | + gotoxy(20, 10); |
| 29 | + cout << "\t3. SafeState Check"; |
| 30 | + gotoxy(20, 12); |
| 31 | + cout << "\t4. SafeSequence of Process"; |
| 32 | + gotoxy(20, 14); |
| 33 | + cout << "\t5. Request Resources"; |
| 34 | + gotoxy(20, 16); |
| 35 | + cout << "\t6. Check Completed Process"; |
| 36 | + gotoxy(20, 18); |
| 37 | + cout << "\t0. Quit"; |
| 38 | + |
| 39 | + gotoxy(32, 25); |
| 40 | + cout << "...Press number..."; |
| 41 | + |
| 42 | + _setcursortype(_NOCURSOR); |
| 43 | + fflush(stdin); |
| 44 | + choice = getch(); |
| 45 | + |
| 46 | + switch (choice) |
| 47 | + { |
| 48 | + case '1': |
| 49 | + _setcursortype(_NORMALCURSOR); |
| 50 | + clrscr(); |
| 51 | + banker.initDATA(1); |
| 52 | + cout << endl; |
| 53 | + banker.validateDATA(); |
| 54 | + banker.checkPRO(); |
| 55 | + cout << endl; |
| 56 | + banker.calcDATA(); |
| 57 | + cout << endl |
| 58 | + << "press any key to continue..."; |
| 59 | + getch(); |
| 60 | + break; |
| 61 | + |
| 62 | + case '2': |
| 63 | + _setcursortype(_NOCURSOR); |
| 64 | + clrscr(); |
| 65 | + banker.snapshot(1); |
| 66 | + gotoxy(26, 24); |
| 67 | + cout << "press any key to continue..."; |
| 68 | + getch(); |
| 69 | + break; |
| 70 | + |
| 71 | + case '3': |
| 72 | + _setcursortype(_NOCURSOR); |
| 73 | + clrscr(); |
| 74 | + banker.snapshot(1); |
| 75 | + cout << endl |
| 76 | + << endl; |
| 77 | + if (banker.isSAFESTATE()) |
| 78 | + cout << endl |
| 79 | + << "SnapShot is in SafeState."; |
| 80 | + else |
| 81 | + cout << endl |
| 82 | + << "SnapShot is in UnSafeState."; |
| 83 | + gotoxy(26, 24); |
| 84 | + cout << "press any key to continue..."; |
| 85 | + getch(); |
| 86 | + break; |
| 87 | + |
| 88 | + case '4': |
| 89 | + _setcursortype(_NOCURSOR); |
| 90 | + clrscr(); |
| 91 | + banker.snapshot(1); |
| 92 | + cout << endl; |
| 93 | + banker.findSAFESEQ(); |
| 94 | + gotoxy(26, 24); |
| 95 | + cout << "press any key to continue..."; |
| 96 | + getch(); |
| 97 | + break; |
| 98 | + |
| 99 | + case '5': |
| 100 | + _setcursortype(_SOLIDCURSOR); |
| 101 | + clrscr(); |
| 102 | + banker.snapshot(); |
| 103 | + cout << endl; |
| 104 | + banker.requestRES(); |
| 105 | + cout << endl |
| 106 | + << "press any key to continue..."; |
| 107 | + getch(); |
| 108 | + break; |
| 109 | + |
| 110 | + case '6': |
| 111 | + _setcursortype(_SOLIDCURSOR); |
| 112 | + clrscr(); |
| 113 | + cout << endl; |
| 114 | + banker.checkPRO(); |
| 115 | + gotoxy(26, 24); |
| 116 | + cout << "press any key to continue..."; |
| 117 | + getch(); |
| 118 | + break; |
| 119 | + |
| 120 | + case '0': |
| 121 | + _setcursortype(_NOCURSOR); |
| 122 | + gotoxy(31, 21); |
| 123 | + cout << "T H A N K Y O U"; |
| 124 | + gotoxy(28, 25); |
| 125 | + cout << "press any key to exit..."; |
| 126 | + getch(); |
| 127 | + goto EXIT; |
| 128 | + |
| 129 | + default: |
| 130 | + _setcursortype(_NOCURSOR); |
| 131 | + gotoxy(28, 22); |
| 132 | + cout << "Please enter valid choice."; |
| 133 | + gotoxy(26, 25); |
| 134 | + cout << "press any key to continue..."; |
| 135 | + getch(); |
| 136 | + break; |
| 137 | + } |
| 138 | + } while (1); |
| 139 | +EXIT: |
| 140 | + return 0; |
| 141 | +} |
0 commit comments