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.

315 lines
10 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
  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 einen guten Test aus?");
  71. sp_textarea_4 = new JScrollPane(textarea_4);
  72. getContentPane().add(sp_textarea_4);
  73. textarea_5 = new JTextArea("textarea_5");
  74. sp_textarea_5 = new JScrollPane(textarea_5);
  75. getContentPane().add(sp_textarea_5);
  76. textarea_6 = new JTextArea("textarea_6");
  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: Maintainable B: C: ");
  94. getContentPane().add(label_10);
  95. textfield_7 = new JTextField("textfield_7");
  96. getContentPane().add(textfield_7);
  97. button_3 = new JButton("Prüfen");
  98. getContentPane().add(button_3);
  99. label_11 = new JLabel("label_11");
  100. getContentPane().add(label_11);
  101. label_12 = new JLabel("label_12");
  102. getContentPane().add(label_12);
  103. textfield_8 = new JTextField("textfield_8");
  104. getContentPane().add(textfield_8);
  105. textfield_9 = new JTextField("textfield_9");
  106. getContentPane().add(textfield_9);
  107. button_4 = new JButton("Prüfen");
  108. getContentPane().add(button_4);
  109. button_5 = new JButton("Prüfen");
  110. getContentPane().add(button_5);
  111. textfield_10 = new JTextField("textfield_10");
  112. getContentPane().add(textfield_10);
  113. label_13 = new JLabel("label_13");
  114. getContentPane().add(label_13);
  115. setSize(getPreferredSize());
  116. addWindowListener(new WindowAdapter() {
  117. public void windowClosing(WindowEvent e) {
  118. System.exit(0);
  119. }
  120. });
  121. }
  122. public static void main(String args[]) {
  123. Quiz_Spiel window = new Quiz_Spiel();
  124. window.setTitle("Quiz_Spiel");
  125. window.pack();
  126. window.show();
  127. }
  128. class CloseListener2 implements ActionListener{
  129. @Override
  130. public void actionPerformed(ActionEvent a) {
  131. if(textfield_4.getText().startsWith("C") || textfield_4.getText().startsWith("c") ) {
  132. System.out.println("ja");
  133. textfield_4.setText("Richtig ! Gewinn 1000 Euro");
  134. JOptionPane.showMessageDialog(null,
  135. "Herzlichen Glückwunsch , Sie sind nicht so dumm, wie ich dachte !",
  136. "Eine Nachricht",
  137. JOptionPane.WARNING_MESSAGE);
  138. }else{
  139. System.out.println("nein");
  140. textfield_4.setText("Falsch geantwortet! ");
  141. }
  142. }
  143. }
  144. class CloseListener implements ActionListener{
  145. @Override
  146. public void actionPerformed(ActionEvent a) {
  147. if(textfield_5.getText().startsWith("B") || textfield_5.getText().startsWith("b") ) {
  148. System.out.println("ja");
  149. textfield_5.setText("Richtig ! Gewinn 1000 Euro");
  150. JOptionPane.showMessageDialog(null,
  151. "Wie viele Windows-Anwender braucht man, um eine Glühbirne zu wechseln? – 100. Einer schraubt und 99 klicken die Fehlermeldungen weg.",
  152. "Eine Nachricht",
  153. JOptionPane.WARNING_MESSAGE);
  154. }else{
  155. System.out.println("nein");
  156. textfield_5.setText("Falsch geantwortet! ");
  157. }
  158. }
  159. }
  160. }
  161. class Quiz_SpielLayout implements LayoutManager {
  162. public Quiz_SpielLayout() {
  163. }
  164. public void addLayoutComponent(String name, Component comp) {
  165. }
  166. public void removeLayoutComponent(Component comp) {
  167. }
  168. public Dimension preferredLayoutSize(Container parent) {
  169. Dimension dim = new Dimension(0, 0);
  170. Insets insets = parent.getInsets();
  171. dim.width = 1050 + insets.left + insets.right;
  172. dim.height = 629 + insets.top + insets.bottom;
  173. return dim;
  174. }
  175. public Dimension minimumLayoutSize(Container parent) {
  176. Dimension dim = new Dimension(0, 0);
  177. return dim;
  178. }
  179. public void layoutContainer(Container parent) {
  180. Insets insets = parent.getInsets();
  181. Component c;
  182. c = parent.getComponent(0);
  183. if (c.isVisible()) {c.setBounds(insets.left+344,insets.top+8,360,32);}
  184. c = parent.getComponent(1);
  185. if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+56,544,40);}
  186. c = parent.getComponent(2);
  187. if (c.isVisible()) {c.setBounds(insets.left+120,insets.top+120,136,32);}
  188. c = parent.getComponent(3);
  189. if (c.isVisible()) {c.setBounds(insets.left+840,insets.top+568,184,32);}
  190. c = parent.getComponent(4);
  191. if (c.isVisible()) {c.setBounds(insets.left+640,insets.top+344,136,32);}
  192. c = parent.getComponent(5);
  193. if (c.isVisible()) {c.setBounds(insets.left+280,insets.top+344,136,32);}
  194. c = parent.getComponent(6);
  195. if (c.isVisible()) {c.setBounds(insets.left+800,insets.top+120,136,32);}
  196. c = parent.getComponent(7);
  197. if (c.isVisible()) {c.setBounds(insets.left+456,insets.top+120,136,32);}
  198. c = parent.getComponent(8);
  199. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+168,288,40);}
  200. c = parent.getComponent(9);
  201. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+168,288,40);}
  202. c = parent.getComponent(10);
  203. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+168,288,40);}
  204. c = parent.getComponent(11);
  205. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+392,288,40);}
  206. c = parent.getComponent(12);
  207. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+392,288,40);}
  208. c = parent.getComponent(13);
  209. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+224,288,32);}
  210. c = parent.getComponent(14);
  211. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+224,288,32);}
  212. c = parent.getComponent(15);
  213. if (c.isVisible()) {c.setBounds(insets.left+48,insets.top+264,200,32);}
  214. c = parent.getComponent(16);
  215. if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+264,80,32);}
  216. c = parent.getComponent(17);
  217. if (c.isVisible()) {c.setBounds(insets.left+384,insets.top+264,200,32);}
  218. c = parent.getComponent(18);
  219. if (c.isVisible()) {c.setBounds(insets.left+592,insets.top+264,80,32);}
  220. c = parent.getComponent(19);
  221. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+224,288,32);}
  222. c = parent.getComponent(20);
  223. if (c.isVisible()) {c.setBounds(insets.left+736,insets.top+264,200,32);}
  224. c = parent.getComponent(21);
  225. if (c.isVisible()) {c.setBounds(insets.left+944,insets.top+264,80,32);}
  226. c = parent.getComponent(22);
  227. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+448,288,32);}
  228. c = parent.getComponent(23);
  229. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+448,288,32);}
  230. c = parent.getComponent(24);
  231. if (c.isVisible()) {c.setBounds(insets.left+200,insets.top+488,200,32);}
  232. c = parent.getComponent(25);
  233. if (c.isVisible()) {c.setBounds(insets.left+560,insets.top+488,200,32);}
  234. c = parent.getComponent(26);
  235. if (c.isVisible()) {c.setBounds(insets.left+408,insets.top+488,80,32);}
  236. c = parent.getComponent(27);
  237. if (c.isVisible()) {c.setBounds(insets.left+768,insets.top+488,80,32);}
  238. c = parent.getComponent(28);
  239. if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+560,128,48);}
  240. c = parent.getComponent(29);
  241. if (c.isVisible()) {c.setBounds(insets.left+16,insets.top+528,128,24);}
  242. }
  243. }