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.

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