Advertisement
KM4WDK

SamOS

Sep 15th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. //SamOS is a basic text based operating system written in C++
  2.  
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <ctime>
  8. #include <thread>
  9. #include <chrono>
  10.  
  11. int login() {
  12.      std::string user = "";
  13.      std::string pass = "";
  14.    
  15.     std::cout << "USERNAME\n";
  16.     std::cin >> user;
  17.    
  18.     std::cout << "PASSWORD\n";
  19.     std::cin >> pass;
  20.    
  21.     if ((user == "samr") && (pass == "samreynolds")){
  22.         std::cout << "LOGIN SUCCESSFUL\n";
  23.     }
  24.    
  25.     else {
  26.         std::cout << "WRONG USERNAME OR PASSWORD\n";
  27.     }
  28. }
  29.  
  30. int currtime() {
  31.     time_t my_time = time(NULL);
  32.         std::cout << ("%s", ctime(&my_time));
  33.         return(0);
  34.   home();
  35. }
  36.  
  37. int home() {
  38.     std::string func = "";
  39.    
  40.     std::cout << "What would you like to do? 'time' 'calculator'\n";
  41.     std::cin >> func;
  42.    
  43.     if (func == "time") {
  44.         currtime();
  45.     }
  46.    
  47.     else if (func == "calculator") {
  48.         calculator();
  49.     }
  50.    
  51.     else {
  52.         std::cout << "INVALID FUNCTION PLEASE TRY AGAIN";
  53.         home();
  54.     }
  55.    
  56. }
  57.  
  58.  
  59. int main() {
  60.     int loads = 0;
  61.     while (loads <= 10) {
  62.     std::cout << "LOADING\n";
  63.     std::this_thread::sleep_for (std::chrono::seconds(1));
  64.     loads = loads + 1;
  65.     }
  66.     std::cout << "Welcome to SamOS\n";
  67.     login();
  68.     home();
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement