Device-Cheat

Untitled

May 5th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.45 KB | None | 0 0
  1. import java.net.UnknownHostException;
  2.  
  3. import com.hazelcast.client.config.ClientConfig;
  4. import com.hazelcast.config.Config;
  5. import com.hazelcast.core.Hazelcast;
  6.  
  7. import com.hazelcast.client.HazelcastClient;
  8. import com.hazelcast.core.HazelcastInstance;
  9. import com.hazelcast.map.IMap;
  10.  
  11. import java.util.Map;
  12. import java.util.Scanner;
  13.  
  14. import java.awt.event.KeyAdapter;
  15. import java.awt.event.KeyEvent;
  16.  
  17. public class HInstance {
  18.  
  19.     public static void main(String[] args) throws UnknownHostException {
  20.         Scanner scan = new Scanner(System.in);
  21.  
  22.         HazelcastInstance hz = HazelcastClient.newHazelcastClient();
  23.  
  24.         IMap map = hz.getMap("firmaa");
  25.  
  26.         System.out.println("Witaj w firmie przewozowej!");
  27.         System.out.println(" ");
  28.  
  29.         System.out.println("1. Dodaj dane kierowcy");
  30.         System.out.println("2. Wyswietl dane kierowcy");
  31.         System.out.println("3. Zmien nazwisko kierowcy");
  32.         System.out.println("4. Usuwanie mapy");
  33.         System.out.println("5. Dopisz nowego studenta do listy");
  34.  
  35.         Integer menuSelected = scan.nextInt();
  36.  
  37.         if(menuSelected == 1){
  38.  
  39.             map.put("Artur", "Urbanski");
  40.             map.get("key");
  41.  
  42.             System.out.println("Dodano Artur -> Urbanski");
  43.             hz.shutdown();
  44.  
  45.         }
  46.  
  47.         if(menuSelected == 2){
  48.             ClientConfig clientConfig = HConfig.getClientConfig();
  49.             HazelcastInstance client = HazelcastClient.newHazelcastClient( clientConfig );
  50.             IMap<Long, Student> students = client.getMap( "firmaa" );
  51.             System.out.println("Wszyscy studenci: ");
  52.             for(Map.Entry<Long, Student> e : students.entrySet()) {
  53.                 System.out.println(e.getKey() + " => " + e.getValue());
  54.  
  55.             }
  56.             hz.shutdown();
  57.         }
  58.  
  59.         if(menuSelected == 3) {
  60.  
  61.            map.get("key");
  62.            map.replace("Artur", "Urbanski", "UrbanskiJava");
  63.  
  64.            System.out.println("Poprawnie zamieniono nazwisko na UrbanskiJava ");
  65.            hz.shutdown();
  66.         }
  67.  
  68.         if(menuSelected == 4){
  69.             hz.getMap("firmaa").destroy();
  70.             System.out.println("Usunieto mape");
  71.             hz.shutdown();
  72.         }
  73.  
  74.         if(menuSelected == 5){
  75.             map.putIfAbsent("Michal", "Kowalski");
  76.             System.out.println("Dopisany do listy nowego studenta!!");
  77.             hz.shutdown();
  78.         }
  79.  
  80.  
  81.         }
  82.     }
  83.  
  84.  
  85. }
  86.  
  87.  
  88.  
  89. github.com/shfx17
Add Comment
Please, Sign In to add comment