Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.06 KB | None | 0 0
  1. //sout - System.out.println("");
  2. import java.util.Scanner;
  3. public class Main {
  4.     public static void main(String[] args) throws Exception {
  5.         boolean zainstalowanySystem = false;
  6.         boolean wlaczonyKomputer = false;
  7.         System.out.println("-----------------------------");
  8.         System.out.println("Symulator włączania komputera");
  9.         System.out.println("-----------------------------");
  10.         System.out.println("[1] Włączanie komputera");
  11.         System.out.println("[2] Wyjście z programu");
  12.         int opcja1 = System.in.read();
  13.         System.out.println("Włączanie komputera...");
  14.         Thread.sleep(3000);
  15.         do
  16.         {
  17.             if (opcja1 == '1') {
  18.                 wlaczonyKomputer = true;
  19.                 System.out.println("[1] Załaduj system");
  20.                 System.out.println("[2] Sprawdź podzespoły");
  21.                 System.out.println("[3] Zainstaluj system");
  22.                 System.out.println("[4] Wyłącz komputer");
  23.                 int opcja2 = 0 ;
  24.                 Scanner odczyt = new Scanner(System.in);
  25.                 opcja2 = odczyt.nextInt();
  26.                 System.out.println(opcja2);
  27.                 clearScreen();
  28.                     if (opcja2 == 1 ) {
  29.                         if (zainstalowanySystem == true){
  30.                             System.out.println("Ładowanie systemu...");
  31.                             Thread.sleep(3000);
  32.                             System.out.println("Witamy w systemie!");
  33.                         }
  34.                         else {
  35.                             System.out.println("System nie został zainstalowany.");
  36.                         }
  37.                     }
  38.                     else if (opcja2 == 2) {
  39.                         System.out.println("Karta graficzna: off (-)");
  40.                         System.out.println("Dysk twardy: on (1TB)");
  41.                         System.out.println("Pamięć ram: on (8Gb)");
  42.                         odliczanie();
  43.                     }
  44.                     else if (opcja2 == 3) {
  45.                         System.out.println("Instalacja systemu...");
  46.                         Thread.sleep(3000);
  47.                         zainstalowanySystem = true;
  48.                         System.out.println("System został poprawnie zainstalowany.");
  49.                         odliczanie();
  50.                     }
  51.                     else if (opcja2 == 4){
  52.                         System.out.println("Wyłączanie komputera...");
  53.                         Thread.sleep(3000);
  54.                         wlaczonyKomputer = false;
  55.                     }
  56.                     else {
  57.                         System.out.println("Wybrałeś złą opcje");
  58.  
  59.                     }
  60.             }
  61.             else if (opcja1 == '2') {
  62.                 System.out.println("Wyłączanie programu...");
  63.                 Thread.sleep(3000);
  64.                 System.exit(System.in.read());
  65.                 break;
  66.             }
  67.  
  68.             else {
  69.                 System.out.println("Wybrałeś złą opcje");
  70.                 break;
  71.             }
  72.  
  73.         } while(wlaczonyKomputer == true);
  74.  
  75.     }
  76.     public static void odliczanie() {
  77.  
  78.         try
  79.         {
  80.             System.out.println("Powrót za: ");
  81.             System.out.println("3");
  82.             Thread.sleep(1000);
  83.             System.out.println("2");
  84.             Thread.sleep(1000);
  85.             System.out.println("1");
  86.             Thread.sleep(1000);
  87.         }
  88.         catch(InterruptedException e)
  89.         {
  90.             // this part is executed when an exception (in this example InterruptedException) occurs
  91.         }
  92.     }
  93.     public static void clearScreen() {
  94.         try
  95.         {
  96.             final String os = System.getProperty("os.name");
  97.  
  98.             if (os.contains("Windows"))
  99.             {
  100.                 Runtime.getRuntime().exec("cls");
  101.             }
  102.             else
  103.             {
  104.                 Runtime.getRuntime().exec("clear");
  105.             }
  106.         }
  107.         catch (final Exception e)
  108.         {
  109.             //  Handle any exceptions.
  110.         }
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement