CI 2019 von Daniel, Eugen und Michael
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

404 lines
13 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. /**
  7. *
  8. * @author Komlovski Eugen
  9. * @version 1.01
  10. * @see /hauch-it/Alpha
  11. *
  12. * */
  13. public class Quiz_Spiel extends JFrame {
  14. JLabel label_1;
  15. JTextArea textarea_1;
  16. JScrollPane sp_textarea_1;
  17. JLabel label_2;
  18. JLabel label_3;
  19. JLabel label_4;
  20. JLabel label_5;
  21. JLabel label_6;
  22. JLabel label_7;
  23. JLabel label_8;
  24. JLabel label_9;
  25. JTextArea textarea_2;
  26. JScrollPane sp_textarea_2;
  27. JTextArea textarea_3;
  28. JScrollPane sp_textarea_3;
  29. JTextArea textarea_4;
  30. JScrollPane sp_textarea_4;
  31. JTextArea textarea_5;
  32. JScrollPane sp_textarea_5;
  33. JTextArea textarea_6;
  34. JScrollPane sp_textarea_6;
  35. JTextField textfield_4;
  36. JButton button_1;
  37. JTextField textfield_5;
  38. JButton button_2;
  39. JLabel label_10;
  40. JTextField textfield_7;
  41. JButton button_3;
  42. JLabel label_11;
  43. JLabel label_12;
  44. JTextField textfield_8;
  45. JTextField textfield_9;
  46. JButton button_4;
  47. JButton button_5;
  48. JTextField textfield_10;
  49. JLabel label_13;
  50. public Quiz_Spiel() {
  51. Quiz_SpielLayout customLayout = new Quiz_SpielLayout();
  52. getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
  53. getContentPane().setLayout(customLayout);
  54. label_1 = new JLabel("Herzlich Willkommen zu unserem Quiz!");
  55. getContentPane().add(label_1);
  56. textarea_1 = new JTextArea("Beantworten Sie uns 5 kurze Fragen und gewinnen Sie 10000 Euro!");
  57. sp_textarea_1 = new JScrollPane(textarea_1);
  58. getContentPane().add(sp_textarea_1);
  59. label_2 = new JLabel("Frage 1:");
  60. getContentPane().add(label_2);
  61. label_3 = new JLabel("Komlovski Eugen");
  62. getContentPane().add(label_3);
  63. label_4 = new JLabel("Frage 5:");
  64. getContentPane().add(label_4);
  65. label_5 = new JLabel("Frage 4:");
  66. getContentPane().add(label_5);
  67. label_6 = new JLabel("Frage 3:");
  68. getContentPane().add(label_6);
  69. label_7 = new JLabel("Frage 2:");
  70. getContentPane().add(label_7);
  71. textarea_2 = new JTextArea("Was gehört nicht zum Test Driven Developement?");
  72. sp_textarea_2 = new JScrollPane(textarea_2);
  73. getContentPane().add(sp_textarea_2);
  74. textarea_3 = new JTextArea("Was ist JUnit?");
  75. sp_textarea_3 = new JScrollPane(textarea_3);
  76. getContentPane().add(sp_textarea_3);
  77. textarea_4 = new JTextArea("Was macht git status?");
  78. sp_textarea_4 = new JScrollPane(textarea_4);
  79. getContentPane().add(sp_textarea_4);
  80. textarea_5 = new JTextArea("Welche Programmiersprache existiert nicht?");
  81. sp_textarea_5 = new JScrollPane(textarea_5);
  82. getContentPane().add(sp_textarea_5);
  83. textarea_6 = new JTextArea("Wie wird ein infizierter Programmcode bezeichnet?");
  84. sp_textarea_6 = new JScrollPane(textarea_6);
  85. getContentPane().add(sp_textarea_6);
  86. label_8 = new JLabel("A: Refactoring B: Transformation C: Clean Code");
  87. getContentPane().add(label_8);
  88. label_9 = new JLabel("A: Sprache B: Framework C: Methode");
  89. getContentPane().add(label_9);
  90. textfield_4 = new JTextField("");
  91. getContentPane().add(textfield_4);
  92. button_1 = new JButton("Prüfen");
  93. getContentPane().add(button_1);
  94. button_1.addActionListener(new CloseListener2());
  95. textfield_5 = new JTextField("");
  96. getContentPane().add(textfield_5);
  97. button_2 = new JButton("Prüfen");
  98. getContentPane().add(button_2);
  99. button_2.addActionListener(new CloseListener());
  100. label_10 = new JLabel("A: Senden B: Speichern C: Änderungen anzeigen ");
  101. getContentPane().add(label_10);
  102. textfield_7 = new JTextField("");
  103. getContentPane().add(textfield_7);
  104. button_3 = new JButton("Prüfen");
  105. getContentPane().add(button_3);
  106. button_3.addActionListener(new CloseListener1());
  107. label_11 = new JLabel("A: C** B: C++ C: C# ");
  108. getContentPane().add(label_11);
  109. label_12 = new JLabel("A: Zecke B: Schlange C: Wurm");
  110. getContentPane().add(label_12);
  111. textfield_8 = new JTextField("");
  112. getContentPane().add(textfield_8);
  113. textfield_9 = new JTextField(""); //Hier
  114. getContentPane().add(textfield_9);
  115. button_4 = new JButton("Prüfen");
  116. getContentPane().add(button_4);
  117. button_4.addActionListener(new CloseListener3());
  118. button_5 = new JButton("Prüfen");
  119. getContentPane().add(button_5);
  120. button_5.addActionListener(new CloseListener4());
  121. textfield_10 = new JTextField("0 Euro");
  122. getContentPane().add(textfield_10);
  123. label_13 = new JLabel("Gewinn:");
  124. getContentPane().add(label_13);
  125. setSize(getPreferredSize());
  126. addWindowListener(new WindowAdapter() {
  127. public void windowClosing(WindowEvent e) {
  128. System.exit(0);
  129. }
  130. });
  131. }
  132. public static void main(String args[]) {
  133. Quiz_Spiel window = new Quiz_Spiel();
  134. window.setTitle("Quiz_Spiel");
  135. window.pack();
  136. window.show();
  137. }
  138. class CloseListener2 implements ActionListener{
  139. /** Methode prüft Eingabe und führt Info raus.
  140. *
  141. *
  142. * @param a Objekt von ActionEvent
  143. *
  144. *
  145. */
  146. @Override
  147. public void actionPerformed(ActionEvent a) {
  148. if(textfield_4.getText().startsWith("C") || textfield_4.getText().startsWith("c") ) {
  149. System.out.println("ja");
  150. textfield_4.setText("Richtig ! Gewinn 2000 Euro");
  151. textfield_10.setText("2000 Euro");
  152. JOptionPane.showMessageDialog(null,
  153. "Herzlichen Glückwunsch , Sie sind nicht so dumm, wie ich dachte !",
  154. "Eine Nachricht",
  155. JOptionPane.WARNING_MESSAGE);
  156. }else{
  157. System.out.println("nein");
  158. textfield_4.setText("Falsch geantwortet! ");
  159. }
  160. }
  161. }
  162. class CloseListener4 implements ActionListener{
  163. @Override
  164. public void actionPerformed(ActionEvent a) {
  165. if(textfield_9.getText().startsWith("C") || textfield_9.getText().startsWith("c") ) {
  166. System.out.println("ja");
  167. textfield_9.setText("Richtig ! Gewinn 2000 Euro");
  168. textfield_10.setText("10000 Euro");
  169. JOptionPane.showMessageDialog(null,
  170. "Herzlichen Glückwunsch, Sie haben 10000 Euro gewonnen!",
  171. "Eine Nachricht",
  172. JOptionPane.WARNING_MESSAGE);
  173. }else{
  174. System.out.println("nein");
  175. textfield_9.setText("Falsch geantwortet! ");
  176. }
  177. }
  178. }
  179. class CloseListener3 implements ActionListener{
  180. @Override
  181. public void actionPerformed(ActionEvent a) {
  182. if(textfield_8.getText().startsWith("A") || textfield_8.getText().startsWith("a") ) {
  183. System.out.println("ja");
  184. textfield_8.setText("Richtig ! Gewinn 2000 Euro");
  185. textfield_10.setText("8000 Euro");
  186. JOptionPane.showMessageDialog(null,
  187. "Gut gemacht, Egal wie leer du bist - es gibt Menschen die sind Lehrer!",
  188. "Eine Nachricht",
  189. JOptionPane.WARNING_MESSAGE);
  190. }else{
  191. System.out.println("nein");
  192. textfield_8.setText("Falsch geantwortet! ");
  193. }
  194. }
  195. }
  196. class CloseListener1 implements ActionListener{
  197. @Override
  198. public void actionPerformed(ActionEvent a) {
  199. if(textfield_7.getText().startsWith("C") || textfield_7.getText().startsWith("c") ) {
  200. System.out.println("ja");
  201. textfield_7.setText("Richtig ! Gewinn 2000 Euro");
  202. textfield_10.setText("6000 Euro");
  203. JOptionPane.showMessageDialog(null,
  204. "HA, gut geraten! Wo ist der beste Ort um eine Leiche zu verstecken? Seite 2 auf Google ",
  205. "Eine Nachricht",
  206. JOptionPane.WARNING_MESSAGE);
  207. }else{
  208. System.out.println("nein");
  209. textfield_7.setText("Falsch geantwortet! ");
  210. }
  211. }
  212. }
  213. class CloseListener implements ActionListener{
  214. @Override
  215. public void actionPerformed(ActionEvent a) {
  216. if(textfield_5.getText().startsWith("B") || textfield_5.getText().startsWith("b") ) {
  217. System.out.println("ja");
  218. textfield_5.setText("Richtig ! Gewinn 2000 Euro");
  219. textfield_10.setText("4000 Euro");
  220. JOptionPane.showMessageDialog(null,
  221. "Wie viele Windows-Anwender braucht man, um eine Glühbirne zu wechseln? – 100. Einer schraubt und 99 klicken die Fehlermeldungen weg.",
  222. "Eine Nachricht",
  223. JOptionPane.WARNING_MESSAGE);
  224. }else{
  225. System.out.println("nein");
  226. textfield_5.setText("Falsch geantwortet! ");
  227. }
  228. }
  229. }
  230. }
  231. class Quiz_SpielLayout implements LayoutManager {
  232. public Quiz_SpielLayout() {
  233. }
  234. public void addLayoutComponent(String name, Component comp) {
  235. }
  236. public void removeLayoutComponent(Component comp) {
  237. }
  238. public Dimension preferredLayoutSize(Container parent) {
  239. Dimension dim = new Dimension(0, 0);
  240. Insets insets = parent.getInsets();
  241. dim.width = 1050 + insets.left + insets.right;
  242. dim.height = 629 + insets.top + insets.bottom;
  243. return dim;
  244. }
  245. public Dimension minimumLayoutSize(Container parent) {
  246. Dimension dim = new Dimension(0, 0);
  247. return dim;
  248. }
  249. public void layoutContainer(Container parent) {
  250. Insets insets = parent.getInsets();
  251. Component c;
  252. c = parent.getComponent(0);
  253. if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+8,360,32);}
  254. c = parent.getComponent(1);
  255. if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+56,544,40);}
  256. c = parent.getComponent(2);
  257. if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+120,136,32);}
  258. c = parent.getComponent(3);
  259. if (c.isVisible()) {c.setBounds(insets.left+840,insets.top+568,184,32);}
  260. c = parent.getComponent(4);
  261. if (c.isVisible()) {c.setBounds(insets.left+640,insets.top+344,136,32);}
  262. c = parent.getComponent(5);
  263. if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+344,136,32);}
  264. c = parent.getComponent(6);
  265. if (c.isVisible()) {c.setBounds(insets.left+800,insets.top+120,136,32);}
  266. c = parent.getComponent(7);
  267. if (c.isVisible()) {c.setBounds(insets.left+456,insets.top+120,136,32);}
  268. c = parent.getComponent(8);
  269. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+168,288,40);}
  270. c = parent.getComponent(9);
  271. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+168,288,40);}
  272. c = parent.getComponent(10);
  273. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+168,288,40);}
  274. c = parent.getComponent(11);
  275. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+392,288,40);}
  276. c = parent.getComponent(12);
  277. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+392,288,40);}
  278. c = parent.getComponent(13);
  279. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+224,288,32);}
  280. c = parent.getComponent(14);
  281. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+224,288,32);}
  282. c = parent.getComponent(15);
  283. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+264,200,32);}
  284. c = parent.getComponent(16);
  285. if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+264,80,32);}
  286. c = parent.getComponent(17);
  287. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+264,200,32);}
  288. c = parent.getComponent(18);
  289. if (c.isVisible()) {c.setBounds(insets.left+592,insets.top+264,80,32);}
  290. c = parent.getComponent(19);
  291. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+224,288,32);}
  292. c = parent.getComponent(20);
  293. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+264,200,32);}
  294. c = parent.getComponent(21);
  295. if (c.isVisible()) {c.setBounds(insets.left+944,insets.top+264,80,32);}
  296. c = parent.getComponent(22);
  297. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+448,288,32);}
  298. c = parent.getComponent(23);
  299. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+448,288,32);}
  300. c = parent.getComponent(24);
  301. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+488,200,32);}
  302. c = parent.getComponent(25);
  303. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+488,200,32);}
  304. c = parent.getComponent(26);
  305. if (c.isVisible()) {c.setBounds(insets.left+408,insets.top+488,80,32);}
  306. c = parent.getComponent(27);
  307. if (c.isVisible()) {c.setBounds(insets.left+768,insets.top+488,80,32);}
  308. c = parent.getComponent(28);
  309. if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+560,128,48);}
  310. c = parent.getComponent(29);
  311. if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+528,128,24);}
  312. }
  313. }