annotate kopieckreta/src/Actions.java @ 24:c7e131ce2f14

makefile rm
author Przemyslaw <prymula76@outlook.com>
date Mon, 01 Apr 2024 07:16:40 +0200
parents 489244127359
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1
prymula <prymula76@outlook.com>
parents:
diff changeset
2 package src;
prymula <prymula76@outlook.com>
parents:
diff changeset
3
prymula <prymula76@outlook.com>
parents:
diff changeset
4 import java.awt.event.KeyEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
5 import java.awt.event.KeyListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
6
prymula <prymula76@outlook.com>
parents:
diff changeset
7 class Actions implements KeyListener {
prymula <prymula76@outlook.com>
parents:
diff changeset
8 String cheat="";
prymula <prymula76@outlook.com>
parents:
diff changeset
9 char pressKey =' ';
prymula <prymula76@outlook.com>
parents:
diff changeset
10
prymula <prymula76@outlook.com>
parents:
diff changeset
11 public void Actions(){}
prymula <prymula76@outlook.com>
parents:
diff changeset
12 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
13 public void keyTyped(KeyEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
14 }
prymula <prymula76@outlook.com>
parents:
diff changeset
15
prymula <prymula76@outlook.com>
parents:
diff changeset
16 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
17 public void keyReleased(KeyEvent event) {
prymula <prymula76@outlook.com>
parents:
diff changeset
18 }
prymula <prymula76@outlook.com>
parents:
diff changeset
19
prymula <prymula76@outlook.com>
parents:
diff changeset
20 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
21 public void keyPressed(KeyEvent event) {
prymula <prymula76@outlook.com>
parents:
diff changeset
22
prymula <prymula76@outlook.com>
parents:
diff changeset
23 if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('a')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
24 isThere('a');
prymula <prymula76@outlook.com>
parents:
diff changeset
25 }
prymula <prymula76@outlook.com>
parents:
diff changeset
26 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('w')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
27 isThere('w');
prymula <prymula76@outlook.com>
parents:
diff changeset
28 }
prymula <prymula76@outlook.com>
parents:
diff changeset
29 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('e')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
30 isThere('e');
prymula <prymula76@outlook.com>
parents:
diff changeset
31 }
prymula <prymula76@outlook.com>
parents:
diff changeset
32 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('r')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
33 isThere('r');
prymula <prymula76@outlook.com>
parents:
diff changeset
34 }
prymula <prymula76@outlook.com>
parents:
diff changeset
35 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('t')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
36 isThere('t');
prymula <prymula76@outlook.com>
parents:
diff changeset
37 }
prymula <prymula76@outlook.com>
parents:
diff changeset
38 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('y')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
39 isThere('y');
prymula <prymula76@outlook.com>
parents:
diff changeset
40 }
prymula <prymula76@outlook.com>
parents:
diff changeset
41 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('u')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
42 isThere('u');
prymula <prymula76@outlook.com>
parents:
diff changeset
43 }
prymula <prymula76@outlook.com>
parents:
diff changeset
44 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('i')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
45 isThere('i');
prymula <prymula76@outlook.com>
parents:
diff changeset
46 }
prymula <prymula76@outlook.com>
parents:
diff changeset
47 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('o')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
48 isThere('o');
prymula <prymula76@outlook.com>
parents:
diff changeset
49 }
prymula <prymula76@outlook.com>
parents:
diff changeset
50 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('p')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
51 isThere('p');
prymula <prymula76@outlook.com>
parents:
diff changeset
52 }
prymula <prymula76@outlook.com>
parents:
diff changeset
53 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('s')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
54 isThere('s');
prymula <prymula76@outlook.com>
parents:
diff changeset
55 }
prymula <prymula76@outlook.com>
parents:
diff changeset
56 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('d')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
57 isThere('d');
prymula <prymula76@outlook.com>
parents:
diff changeset
58 }
prymula <prymula76@outlook.com>
parents:
diff changeset
59 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('f')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
60 isThere('f');
prymula <prymula76@outlook.com>
parents:
diff changeset
61 }
prymula <prymula76@outlook.com>
parents:
diff changeset
62 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('g')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
63 isThere('g');
prymula <prymula76@outlook.com>
parents:
diff changeset
64 }
prymula <prymula76@outlook.com>
parents:
diff changeset
65 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('h')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
66 isThere('h');
prymula <prymula76@outlook.com>
parents:
diff changeset
67 }
prymula <prymula76@outlook.com>
parents:
diff changeset
68 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('j')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
69 isThere('j');
prymula <prymula76@outlook.com>
parents:
diff changeset
70 }
prymula <prymula76@outlook.com>
parents:
diff changeset
71 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('k')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
72 isThere('k');
prymula <prymula76@outlook.com>
parents:
diff changeset
73 }
prymula <prymula76@outlook.com>
parents:
diff changeset
74 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('l')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
75 isThere('l');
prymula <prymula76@outlook.com>
parents:
diff changeset
76 }
prymula <prymula76@outlook.com>
parents:
diff changeset
77 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('z')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
78 isThere('z');
prymula <prymula76@outlook.com>
parents:
diff changeset
79 }
prymula <prymula76@outlook.com>
parents:
diff changeset
80 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('c')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
81 isThere('c');
prymula <prymula76@outlook.com>
parents:
diff changeset
82 }
prymula <prymula76@outlook.com>
parents:
diff changeset
83 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('b')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
84 isThere('b');
prymula <prymula76@outlook.com>
parents:
diff changeset
85 }
prymula <prymula76@outlook.com>
parents:
diff changeset
86 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('n')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
87 isThere('n');
prymula <prymula76@outlook.com>
parents:
diff changeset
88 }
prymula <prymula76@outlook.com>
parents:
diff changeset
89 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('m')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
90 isThere('m');
prymula <prymula76@outlook.com>
parents:
diff changeset
91 }
prymula <prymula76@outlook.com>
parents:
diff changeset
92 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('1')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
93 hungryCheat('1');
prymula <prymula76@outlook.com>
parents:
diff changeset
94 }
prymula <prymula76@outlook.com>
parents:
diff changeset
95 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('2')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
96 hungryCheat('2');
prymula <prymula76@outlook.com>
parents:
diff changeset
97 }
prymula <prymula76@outlook.com>
parents:
diff changeset
98 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('3')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
99 hungryCheat('3');
prymula <prymula76@outlook.com>
parents:
diff changeset
100 }
prymula <prymula76@outlook.com>
parents:
diff changeset
101 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('4')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
102 hungryCheat('4');
prymula <prymula76@outlook.com>
parents:
diff changeset
103 }
prymula <prymula76@outlook.com>
parents:
diff changeset
104 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar(' ')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
105 resetCheat();
prymula <prymula76@outlook.com>
parents:
diff changeset
106 }
prymula <prymula76@outlook.com>
parents:
diff changeset
107
prymula <prymula76@outlook.com>
parents:
diff changeset
108 }
prymula <prymula76@outlook.com>
parents:
diff changeset
109 public char getKey () {
prymula <prymula76@outlook.com>
parents:
diff changeset
110 return pressKey;
prymula <prymula76@outlook.com>
parents:
diff changeset
111 }
prymula <prymula76@outlook.com>
parents:
diff changeset
112 public String getCheat(){
prymula <prymula76@outlook.com>
parents:
diff changeset
113 return cheat;
prymula <prymula76@outlook.com>
parents:
diff changeset
114 }
prymula <prymula76@outlook.com>
parents:
diff changeset
115
prymula <prymula76@outlook.com>
parents:
diff changeset
116 private void isThere(char c){
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
117 // Nie wiem czemu od razu nie przekazalem duzej litery...
0
prymula <prymula76@outlook.com>
parents:
diff changeset
118 pressKey=Character.toUpperCase(c);
prymula <prymula76@outlook.com>
parents:
diff changeset
119 resetCheat();
prymula <prymula76@outlook.com>
parents:
diff changeset
120 }
prymula <prymula76@outlook.com>
parents:
diff changeset
121 private void hungryCheat(char c){
prymula <prymula76@outlook.com>
parents:
diff changeset
122 String s =Character.toString(c);
prymula <prymula76@outlook.com>
parents:
diff changeset
123 cheat += s;
prymula <prymula76@outlook.com>
parents:
diff changeset
124 }
prymula <prymula76@outlook.com>
parents:
diff changeset
125 public void resetCheat(){
prymula <prymula76@outlook.com>
parents:
diff changeset
126 cheat="";
prymula <prymula76@outlook.com>
parents:
diff changeset
127 }
prymula <prymula76@outlook.com>
parents:
diff changeset
128 }