Advertisement
Guest User

Michael's Project

a guest
Apr 7th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.84 KB | None | 0 0
  1. // QA 3 Final George Dawoud and Michael Park, PC simulation
  2. #include <iostream>
  3. #include <string.h>
  4. using namespace std;
  5.  
  6. void login(); // login function
  7. void boot(); // boot function
  8. void powerschool(); // powerschool program has structures
  9. void schedule(); // schedule program has 2 dimsensional array
  10. void systemcheck(); //function
  11. void logoff(); // function with exit 0 to log off
  12. void reboot(); //restarts program with all functions
  13. void shutdown(); //terminates program
  14. void oprions(); // all the operations of the computer in a function
  15.  
  16. class Options {
  17. public:
  18. static void powerschool() {
  19.  
  20. struct numbers { // structures with integers and chars for program id
  21. char last_name[12];
  22. char first_name[12];
  23. int phonenumber;
  24. double age;
  25. };
  26.  
  27.  
  28. numbers stu;
  29. cout << " you will know create your powerschool id for prep. answer the questions below. " << endl;
  30. cout << "What is your first name? " << endl;
  31. cin >> stu.first_name; // structure containing name up to 12 characters
  32. cout << "What is your last name? " << endl;
  33. cin >> stu.last_name; // structure with last name up to 12 letters
  34. cout << "What is your age? " << endl;
  35. cin >> stu.age; // double age in structure
  36. cout << "What is your phone number? " << endl;
  37. cin >> stu.phonenumber; // phone number up to 12 numbers for extension etc
  38. cout << "Your name, age and number is " << endl;
  39. cout << stu.first_name << " " << stu.last_name << " " << stu.age << " " << stu.phonenumber; // prints out all the information
  40. }
  41.  
  42.  
  43. static void schedule() { // schedule program
  44. const int day = 3;
  45. const int classs = 6;
  46.  
  47. int times[day][classs];
  48. cout << "In prep you get to make your own schedule. You have 6 classes a day for your 3 day schedule please record what time your classes are to print out the time of your schedule." << endl;
  49. cout << "If your classes start a specific time type it as a 3 digit number, i.e. 8:30 would be 830" << endl;
  50. for (int i = 0; i < day; ++i) {
  51. for(int j = 0; j < classs; ++j) {
  52. cout << "day "<<i+1<<", class "<<j+1<<" : ";
  53. cin >> times[i][j];
  54. }
  55. }
  56. cout << endl << endl << "Displaying times of classes" << endl;
  57. for (int i = 0; i < day; ++i)
  58. {
  59. for(int j = 0; j < classs; ++j) {
  60. cout << "Day "<<i+1<<", class "<< j+1 << " = " << times[i][j]<<endl;
  61. }
  62. }
  63. }
  64.  
  65. static void systemcheck() { // system check prints the pointers below
  66. int tempmax = 203;
  67. int *x; // adress and pointer
  68. x = &tempmax;
  69. int tempmin = 170;
  70. int *y; // adress and pointer
  71. y = &tempmin;
  72. cout << "system check is now running " << endl << "1.....2......3...... DONE!!!" << endl;
  73. cout << "The following programs running in the backgroud are: Schedule, Powerschool, and system check." << endl;
  74. cout << "The devices connected are a moniter via vga, a usb li12 keyboard and razer mouse" <<endl;
  75. cout << "Specs are : intel i5 4790k, nvidia gtx 770ti, 8gb kingston ram, hyper evo 212 cooler, seagate ssd, western digital hdd. " << endl;
  76. cout << "Current cores used: 2, current temp due to evo 212 ranges from " << *y << "to " << *x << endl;
  77. }
  78. static void options() {
  79. int choice2;
  80. int choice3;
  81.  
  82. cout << endl << "what would you like to do now : 1. Logoff" << endl << "2. Reboot " << endl << "3. Shutdown" << "4. Systemcheck" ;
  83. cout << "5. Open a program " << endl;
  84. cin >> choice2;
  85. if (choice2 == 1) { // if you choos to logoff it will logoff and go back to boot menu
  86. logoff();
  87. }
  88. else if (choice2 == 2) {
  89. reboot(); // if you choose to rebooot it takes you back to the boot meny
  90. }
  91. else if (choice2 == 3) {
  92. shutdown(); // terminates program via exit 0
  93. }
  94. else if (choice2 == 4) {
  95. systemcheck(); // shows programs running, program that prints pointers
  96. }
  97. else if (choice2 == 5) {
  98. cout << "which program would you like to run? 1) Powerschool ID or 2) schedule. Enter your choice " << endl;
  99. cin >> choice3;
  100. if (choice3 == 1) { // if you choose to run this program it runs and loops back to options menu
  101. powerschool();
  102. options();
  103. }
  104. else if (choice3 == 2) { // runs program then loops back to options menu
  105. schedule();
  106. options();
  107. }
  108. else { // if the user doesnt enter one of the numbers this prints
  109. cout << "please enter a valid choice" << endl;
  110. }
  111. }
  112. else { // if the user doesnt enter one of the numbers this prints
  113. cout << "please enter a valid choice" << endl;
  114. }
  115. };
  116.  
  117. class Power { // second class with boot options etc
  118. public:
  119. static void shutdown() {
  120. cout << "computer will now shutdown 3.....2......1" <<endl;
  121. exit(0); // terminates program
  122.  
  123. }
  124. static void reboot() { // reboot prints cout and runs boot
  125.  
  126. cout << "computer will now reboot 3....2....1";
  127. boot();
  128. }
  129.  
  130. static void logoff() {
  131. int choice1;
  132.  
  133. cout << endl << "would you like to log off? If yes press 1 if not 2" << endl;
  134. cin >> choice1;
  135. if (choice1==1) {
  136. cout << "you will now log off in 3....2...1." << endl;
  137. login();
  138. }
  139. else if (choice1==2) { // continues the run program
  140. cout << " you will stay logged in dont worry what you have done so far will stay open" << endl;
  141. }
  142. else {
  143. cout << "please enter a valid option so that you may stay logged in or log off" <<endl;
  144. }
  145. }
  146.  
  147. static void login() {// login function
  148.  
  149. char username[5],password[4]; // characters for the username and password
  150.  
  151. const char* USERNAME = "ADMIN"; // Given username
  152. const char* PASSWORD = "pass"; // Given password
  153. int choice4;
  154.  
  155. cout << "would you like to log in or shutdown? 1. log in 2. Shutdown" << endl;
  156. cin >> choice4;
  157. if (choice4 == 1) { // if you choose to log in strcmp follows
  158. cout << "please login to use the computer" <<endl;
  159. cout << "Username is 'ADMIN' and password is 'pass' " << endl;
  160. cout << " Username: ";
  161. cin >> username; // input username
  162. cout << " Password: ";
  163. cin >> password; // input password
  164.  
  165. if (strcmp (username,USERNAME) == 0) // comparing the input username to given username to see if its the same (if works continue)
  166. {
  167. if (strcmp (password,PASSWORD) == 0) // checks if input password is the same as given password (if work continue)
  168. {
  169. cout << "you have succesfully loged in. ";
  170. }
  171. else {
  172. cout << "please try again username or password incorrect"; // if either the username or password is incorrect this will display and you will retry
  173. }
  174. }
  175. else if (choice4 == 2) {
  176. shutdown(); // terminates program
  177. }
  178. }
  179. }
  180.  
  181. static void boot() { // the booting from drives and system check for moniter, keyboard, and mouse
  182. int choice;
  183.  
  184. cout << "welcome to prep osxii. this is a prep computer and operating system designed to help you with your powerschool, schedule and to ensure all is well is make sure the color of your screen is blue if not unplug and plug in again to see if the lighting is working correctly.";
  185. cout << endl << "we will now do a scan to ensure the drivers for your mouse and keyboard are up to date.";
  186. cout << endl << "1....2....3... Great both your mouse and keyboard are connected. You will now boot into the bios ";
  187. cout << endl << "Would you like to boot from your hard drive or ssd? type 1 for hdd or 2 for ssd";
  188. cin >> choice;
  189. if ( choice == 1 ) { // if correct boots from hdd if not will have to retry
  190. cout << "you will now boot from the hdd";
  191. }
  192. else if ( choice == 2) {
  193. cout << " you will now boot from the ssd";
  194. }
  195. else {
  196. cout << "not a valid option retry";
  197. }
  198. }
  199. };
  200.  
  201. int main() {
  202. Power::boot();
  203. return 0;
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement