diff kopieckreta/src/Actions.java @ 0:2787f5e749ae

INIT
author prymula <prymula76@outlook.com>
date Thu, 21 Sep 2023 22:33:57 +0200
parents
children 489244127359
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kopieckreta/src/Actions.java	Thu Sep 21 22:33:57 2023 +0200
@@ -0,0 +1,155 @@
+
+package src;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+class Actions implements KeyListener {
+    String cheat="";
+    char pressKey =' ';
+    
+    public void Actions(){}
+    @Override
+    public void keyTyped(KeyEvent e) {
+    }
+
+    @Override
+    public void keyReleased(KeyEvent event) {
+    }
+
+    @Override
+    public void keyPressed(KeyEvent event) {
+    
+        if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('a')) {
+            isThere('a');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ą')) {
+            isThere('ą');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('w')) {
+            isThere('w');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('e')) {
+            isThere('e');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ę')) {
+            isThere('ę');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('r')) {
+            isThere('r');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('t')) {
+            isThere('t');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('y')) {
+            isThere('y');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('u')) {
+            isThere('u');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('i')) {
+            isThere('i');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('o')) {
+            isThere('o');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ó')) {
+            isThere('ó');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('p')) {
+            isThere('p');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('s')) {
+            isThere('s');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ś')) {
+            isThere('ś');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('d')) {
+            isThere('d');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('f')) {
+            isThere('f');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('g')) {
+            isThere('g');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('h')) {
+            isThere('h');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('j')) {
+            isThere('j');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('k')) {
+            isThere('k');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('l')) {
+            isThere('l');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ł')) {
+            isThere('ł');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('z')) {
+            isThere('z');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ż')) {
+            isThere('ż');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ź')) {
+            isThere('ź');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('c')) {
+            isThere('c');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ć')) {
+            isThere('ć');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('b')) {
+            isThere('b');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('n')) {
+            isThere('n');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ń')) {
+            isThere('ń');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('m')) {
+            isThere('m');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('1')) {
+            hungryCheat('1');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('2')) {
+            hungryCheat('2');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('3')) {
+            hungryCheat('3');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('4')) {
+            hungryCheat('4');
+        }
+        else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar(' ')) {
+            resetCheat();
+        }
+        
+    }
+    public char getKey () {
+        return pressKey;
+    }
+    public String getCheat(){
+        return cheat;
+    }
+    
+    private void isThere(char c){
+        // Nie wiem czemu od razu nie przekazałem dużej litery...
+        pressKey=Character.toUpperCase(c);
+        resetCheat();
+    }
+    private void hungryCheat(char c){
+        String s =Character.toString(c);
+        cheat += s;
+    }
+    public void resetCheat(){
+        cheat="";
+    }
+}