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.

397 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. 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("0 Euro");
  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. /** Methode prüft Eingabe und führt Info raus.
  133. *
  134. *
  135. * @param a Objekt von ActionEvent
  136. *
  137. *
  138. */
  139. @Override
  140. public void actionPerformed(ActionEvent a) {
  141. if(textfield_4.getText().startsWith("C") || textfield_4.getText().startsWith("c") ) {
  142. System.out.println("ja");
  143. textfield_4.setText("Richtig ! Gewinn 2000 Euro");
  144. textfield_10.setText("2000 Euro");
  145. JOptionPane.showMessageDialog(null,
  146. "Herzlichen Glückwunsch , Sie sind nicht so dumm, wie ich dachte !",
  147. "Eine Nachricht",
  148. JOptionPane.WARNING_MESSAGE);
  149. }else{
  150. System.out.println("nein");
  151. textfield_4.setText("Falsch geantwortet! ");
  152. }
  153. }
  154. }
  155. class CloseListener4 implements ActionListener{
  156. @Override
  157. public void actionPerformed(ActionEvent a) {
  158. if(textfield_9.getText().startsWith("C") || textfield_9.getText().startsWith("c") ) {
  159. System.out.println("ja");
  160. textfield_9.setText("Richtig ! Gewinn 2000 Euro");
  161. textfield_10.setText("10000 Euro");
  162. JOptionPane.showMessageDialog(null,
  163. "Herzlichen Glückwunsch, Sie haben 10000 Euro gewonnen!",
  164. "Eine Nachricht",
  165. JOptionPane.WARNING_MESSAGE);
  166. }else{
  167. System.out.println("nein");
  168. textfield_9.setText("Falsch geantwortet! ");
  169. }
  170. }
  171. }
  172. class CloseListener3 implements ActionListener{
  173. @Override
  174. public void actionPerformed(ActionEvent a) {
  175. if(textfield_8.getText().startsWith("A") || textfield_8.getText().startsWith("a") ) {
  176. System.out.println("ja");
  177. textfield_8.setText("Richtig ! Gewinn 2000 Euro");
  178. textfield_10.setText("8000 Euro");
  179. JOptionPane.showMessageDialog(null,
  180. "Gut gemacht, Egal wie leer du bist - es gibt Menschen die sind Lehrer!",
  181. "Eine Nachricht",
  182. JOptionPane.WARNING_MESSAGE);
  183. }else{
  184. System.out.println("nein");
  185. textfield_8.setText("Falsch geantwortet! ");
  186. }
  187. }
  188. }
  189. class CloseListener1 implements ActionListener{
  190. @Override
  191. public void actionPerformed(ActionEvent a) {
  192. if(textfield_7.getText().startsWith("C") || textfield_7.getText().startsWith("c") ) {
  193. System.out.println("ja");
  194. textfield_7.setText("Richtig ! Gewinn 2000 Euro");
  195. textfield_10.setText("6000 Euro");
  196. JOptionPane.showMessageDialog(null,
  197. "HA, gut geraten! Wo ist der beste Ort um eine Leiche zu verstecken? Seite 2 auf Google ",
  198. "Eine Nachricht",
  199. JOptionPane.WARNING_MESSAGE);
  200. }else{
  201. System.out.println("nein");
  202. textfield_7.setText("Falsch geantwortet! ");
  203. }
  204. }
  205. }
  206. class CloseListener implements ActionListener{
  207. @Override
  208. public void actionPerformed(ActionEvent a) {
  209. if(textfield_5.getText().startsWith("B") || textfield_5.getText().startsWith("b") ) {
  210. System.out.println("ja");
  211. textfield_5.setText("Richtig ! Gewinn 2000 Euro");
  212. textfield_10.setText("4000 Euro");
  213. JOptionPane.showMessageDialog(null,
  214. "Wie viele Windows-Anwender braucht man, um eine Glühbirne zu wechseln? – 100. Einer schraubt und 99 klicken die Fehlermeldungen weg.",
  215. "Eine Nachricht",
  216. JOptionPane.WARNING_MESSAGE);
  217. }else{
  218. System.out.println("nein");
  219. textfield_5.setText("Falsch geantwortet! ");
  220. }
  221. }
  222. }
  223. }
  224. class Quiz_SpielLayout implements LayoutManager {
  225. public Quiz_SpielLayout() {
  226. }
  227. public void addLayoutComponent(String name, Component comp) {
  228. }
  229. public void removeLayoutComponent(Component comp) {
  230. }
  231. public Dimension preferredLayoutSize(Container parent) {
  232. Dimension dim = new Dimension(0, 0);
  233. Insets insets = parent.getInsets();
  234. dim.width = 1050 + insets.left + insets.right;
  235. dim.height = 629 + insets.top + insets.bottom;
  236. return dim;
  237. }
  238. public Dimension minimumLayoutSize(Container parent) {
  239. Dimension dim = new Dimension(0, 0);
  240. return dim;
  241. }
  242. public void layoutContainer(Container parent) {
  243. Insets insets = parent.getInsets();
  244. Component c;
  245. c = parent.getComponent(0);
  246. if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+8,360,32);}
  247. c = parent.getComponent(1);
  248. if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+56,544,40);}
  249. c = parent.getComponent(2);
  250. if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+120,136,32);}
  251. c = parent.getComponent(3);
  252. if (c.isVisible()) {c.setBounds(insets.left+840,insets.top+568,184,32);}
  253. c = parent.getComponent(4);
  254. if (c.isVisible()) {c.setBounds(insets.left+640,insets.top+344,136,32);}
  255. c = parent.getComponent(5);
  256. if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+344,136,32);}
  257. c = parent.getComponent(6);
  258. if (c.isVisible()) {c.setBounds(insets.left+800,insets.top+120,136,32);}
  259. c = parent.getComponent(7);
  260. if (c.isVisible()) {c.setBounds(insets.left+456,insets.top+120,136,32);}
  261. c = parent.getComponent(8);
  262. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+168,288,40);}
  263. c = parent.getComponent(9);
  264. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+168,288,40);}
  265. c = parent.getComponent(10);
  266. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+168,288,40);}
  267. c = parent.getComponent(11);
  268. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+392,288,40);}
  269. c = parent.getComponent(12);
  270. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+392,288,40);}
  271. c = parent.getComponent(13);
  272. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+224,288,32);}
  273. c = parent.getComponent(14);
  274. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+224,288,32);}
  275. c = parent.getComponent(15);
  276. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+264,200,32);}
  277. c = parent.getComponent(16);
  278. if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+264,80,32);}
  279. c = parent.getComponent(17);
  280. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+264,200,32);}
  281. c = parent.getComponent(18);
  282. if (c.isVisible()) {c.setBounds(insets.left+592,insets.top+264,80,32);}
  283. c = parent.getComponent(19);
  284. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+224,288,32);}
  285. c = parent.getComponent(20);
  286. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+264,200,32);}
  287. c = parent.getComponent(21);
  288. if (c.isVisible()) {c.setBounds(insets.left+944,insets.top+264,80,32);}
  289. c = parent.getComponent(22);
  290. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+448,288,32);}
  291. c = parent.getComponent(23);
  292. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+448,288,32);}
  293. c = parent.getComponent(24);
  294. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+488,200,32);}
  295. c = parent.getComponent(25);
  296. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+488,200,32);}
  297. c = parent.getComponent(26);
  298. if (c.isVisible()) {c.setBounds(insets.left+408,insets.top+488,80,32);}
  299. c = parent.getComponent(27);
  300. if (c.isVisible()) {c.setBounds(insets.left+768,insets.top+488,80,32);}
  301. c = parent.getComponent(28);
  302. if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+560,128,48);}
  303. c = parent.getComponent(29);
  304. if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+528,128,24);}
  305. }
  306. }