Facebook
From Capacious Lechwe, 6 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 250
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package pkg0407;
  7.  
  8. import java.util.HashMap;
  9. import java.util.Map;
  10. import java.util.Scanner;
  11.  
  12. /**
  13.  *
  14.  * @author Admin
  15.  */
  16. public class Main {
  17.  
  18.     /**
  19.      * @param args the command line arguments
  20.      */
  21.     public static void main(String[] args) {
  22.         Scanner le = new Scanner(System.in);
  23.         Map<String, String> mapa = new HashMap<String, String>();
  24.         mapa.put("piotr", "lala");
  25.         System.out.println("podaj login");
  26.         String getlogin = le.nextLine();
  27.  
  28.         while (!mapa.containsKey(getlogin)) {
  29.             if (mapa.containsKey(getlogin)) {
  30.                 String haslo = mapa.get(getlogin);
  31.                 System.out.println("Podaj haslo");
  32.                 String gethaslo = le.nextLine();
  33.                 le.nextLine();
  34.                 if (gethaslo.equals(mapa.get(getlogin))) {
  35.                     break;
  36.                 } else {
  37.                     System.out.println("zle haslo");
  38.                 }
  39.             } else {
  40.                 System.out.println("Zly login");
  41.                 getlogin = le.nextLine();
  42.             }
  43.         }
  44.  
  45.     }
  46. }
  47.