Update
parent
d7836fd17c
commit
7aa59568dc
30
.classpath
30
.classpath
|
@ -1,15 +1,15 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="Programmierung2/src"/>
|
<classpathentry kind="src" path="Programmierung2/src"/>
|
||||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,55 +1,54 @@
|
||||||
package BankSystemGUI;
|
package BankSystemGUI;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
class JTest {
|
||||||
class JTest {
|
User obai;
|
||||||
User obai;
|
Konto obai_konto, obai_konto2;
|
||||||
Konto obai_konto, obai_konto2;
|
|
||||||
|
User omar;
|
||||||
User omar;
|
Konto omar_konto;
|
||||||
Konto omar_konto;
|
|
||||||
|
Bank bank;
|
||||||
Bank bank;
|
|
||||||
|
@BeforeEach
|
||||||
@BeforeEach
|
void erstelle_Objekt() {
|
||||||
void erstelle_Objekt() {
|
obai = new User("Obai","albek");
|
||||||
obai = new User("Obai","albek");
|
obai_konto = new Konto(0,obai);
|
||||||
obai_konto = new Konto(0,obai);
|
obai_konto2 = new Konto(0,obai);
|
||||||
obai_konto2 = new Konto(0,obai);
|
|
||||||
|
omar = new User("Omar","Albek");
|
||||||
omar = new User("Omar","Albek");
|
omar_konto = new Konto(0,omar);
|
||||||
omar_konto = new Konto(0,omar);
|
|
||||||
|
bank = new Bank("SparKasse");
|
||||||
bank = new Bank("SparKasse");
|
|
||||||
|
bank.kunde_Hinzufuegen(obai);
|
||||||
bank.kunde_Hinzufuegen(obai);
|
bank.kunde_Hinzufuegen(omar);
|
||||||
bank.kunde_Hinzufuegen(omar);
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void sucheKunden() throws Exception {
|
||||||
public void sucheKunden() throws Exception {
|
|
||||||
|
assertEquals(omar.toString(),bank.getKunde(1003));
|
||||||
assertEquals(omar.toString(),bank.getKunde(1003));
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
void testeinzahlen() throws Exception {
|
||||||
void testeinzahlen() throws Exception {
|
obai_konto.einzahlen(50);
|
||||||
obai_konto.einzahlen(50);
|
assertEquals(50,obai_konto.getKontostand());
|
||||||
assertEquals(50,obai_konto.getKontostand());
|
|
||||||
|
obai_konto2.einzahlen(100);
|
||||||
obai_konto2.einzahlen(100);
|
assertEquals(100,obai_konto2.getKontostand());
|
||||||
assertEquals(100,obai_konto2.getKontostand());
|
|
||||||
|
omar_konto.einzahlen(100);
|
||||||
omar_konto.einzahlen(100);
|
assertEquals(100,omar_konto.getKontostand());
|
||||||
assertEquals(100,omar_konto.getKontostand());
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package BinaryTree;
|
package BinaryTree;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
class JuintTeste {
|
class JuintTeste {
|
||||||
|
|
||||||
@Test
|
|
||||||
void test() {
|
void test() {
|
||||||
BinaryBaumList b1 = new BinaryBaumList();
|
BinaryBaumList b1 = new BinaryBaumList();
|
||||||
b1.addElement(15);
|
b1.addElement(15);
|
||||||
|
|
|
@ -3,32 +3,34 @@ package BinaryTree;
|
||||||
public class Test {
|
public class Test {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
BinaryBaumList b1 = new BinaryBaumList();
|
// BinaryBaumList b1 = new BinaryBaumList();
|
||||||
b1.addElement(50);
|
// b1.addElement(50);
|
||||||
b1.addElement(30);
|
// b1.addElement(30);
|
||||||
b1.addElement(70);
|
// b1.addElement(70);
|
||||||
b1.addElement(20);
|
// b1.addElement(20);
|
||||||
b1.addElement(40);
|
// b1.addElement(40);
|
||||||
b1.addElement(60);
|
// b1.addElement(60);
|
||||||
b1.addElement(80);
|
// b1.addElement(80);
|
||||||
b1.addElement(15);
|
// b1.addElement(15);
|
||||||
b1.addElement(22);
|
// b1.addElement(22);
|
||||||
b1.addElement(35);
|
// b1.addElement(35);
|
||||||
b1.addElement(45);
|
// b1.addElement(45);
|
||||||
b1.addElement(21);
|
// b1.addElement(21);
|
||||||
b1.addElement(25);
|
// b1.addElement(25);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// System.out.print("[");
|
||||||
|
// b1.printDepth();
|
||||||
|
// System.out.print("]");
|
||||||
|
// System.out.println();
|
||||||
|
// b1.removNode(30);
|
||||||
|
// System.out.print("[");
|
||||||
|
// b1.printDepth();
|
||||||
|
// System.out.print("]");
|
||||||
|
|
||||||
System.out.print("[");
|
System.out.println('G' > 'F');
|
||||||
b1.printDepth();
|
|
||||||
System.out.print("]");
|
|
||||||
System.out.println();
|
|
||||||
b1.removNode(30);
|
|
||||||
System.out.print("[");
|
|
||||||
b1.printDepth();
|
|
||||||
System.out.print("]");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -2,14 +2,12 @@ package GUIAnwendungen;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
@ -30,7 +28,6 @@ public class Jpanel {
|
||||||
|
|
||||||
// و وضعنا له حدود و عنوان Layout Manager لا يستخدم أي Panel هنا قمنا بتعريف
|
// و وضعنا له حدود و عنوان Layout Manager لا يستخدم أي Panel هنا قمنا بتعريف
|
||||||
JPanel panel = new JPanel(null);
|
JPanel panel = new JPanel(null);
|
||||||
panel.setBorder(BorderFactory.createTitledBorder("Add User"));
|
|
||||||
panel.setBounds(50, 30, 290, 300);
|
panel.setBounds(50, 30, 290, 300);
|
||||||
|
|
||||||
// Frame في الـ Panel هنا وضعنا الـ
|
// Frame في الـ Panel هنا وضعنا الـ
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.awt.Font;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
@ -28,7 +27,6 @@ public class Labels {
|
||||||
JLabel label = new JLabel();
|
JLabel label = new JLabel();
|
||||||
|
|
||||||
// Erstelle einen Border für das Fenster
|
// Erstelle einen Border für das Fenster
|
||||||
Border b1 = BorderFactory.createLineBorder(Color.GREEN,5);
|
|
||||||
|
|
||||||
// füge den Text auf dem Fenster hinzu
|
// füge den Text auf dem Fenster hinzu
|
||||||
label.setText("Hall Welt");
|
label.setText("Hall Welt");
|
||||||
|
@ -60,7 +58,6 @@ public class Labels {
|
||||||
label.setOpaque(true);
|
label.setOpaque(true);
|
||||||
|
|
||||||
//zeige den Border auf dem Fenster
|
//zeige den Border auf dem Fenster
|
||||||
label.setBorder(b1);
|
|
||||||
|
|
||||||
|
|
||||||
//füge ein Bild hinzu
|
//füge ein Bild hinzu
|
||||||
|
|
|
@ -2,7 +2,6 @@ package GUIAnwendungen;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
|
@ -1,47 +1,45 @@
|
||||||
package Hashmap;
|
package Hashmap;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import Hashmap.MyGenericHashMap.Entry;
|
class JunitTest {
|
||||||
|
private MyGenericHashMap<Integer,String> h1;
|
||||||
class JunitTest {
|
@BeforeEach
|
||||||
private MyGenericHashMap<Integer,String> h1;
|
void list() {
|
||||||
@BeforeEach
|
h1 = new MyGenericHashMap<>();
|
||||||
void list() {
|
h1.put(3009594, "obai");
|
||||||
h1 = new MyGenericHashMap<>();
|
h1.put(3129594, "omar");
|
||||||
h1.put(3009594, "obai");
|
h1.put(3129592, "abd");
|
||||||
h1.put(3129594, "omar");
|
h1.put(3129392, "basel");
|
||||||
h1.put(3129592, "abd");
|
}
|
||||||
h1.put(3129392, "basel");
|
|
||||||
}
|
@Test
|
||||||
|
void testPut() {
|
||||||
@Test
|
h1.put(3009594, "omar");
|
||||||
void testPut() {
|
String value = h1.getValue(3009594);
|
||||||
h1.put(3009594, "omar");
|
assertEquals("omar",value);
|
||||||
String value = h1.getValue(3009594);
|
|
||||||
assertEquals("omar",value);
|
}
|
||||||
|
|
||||||
}
|
@Test
|
||||||
|
void testcontainsKey() {
|
||||||
@Test
|
assertTrue(h1.containsKey(3129592));
|
||||||
void testcontainsKey() {
|
assertFalse(h1.containsKey(3213213));
|
||||||
assertTrue(h1.containsKey(3129592));
|
}
|
||||||
assertFalse(h1.containsKey(3213213));
|
|
||||||
}
|
@Test
|
||||||
|
void testSize() {
|
||||||
@Test
|
assertEquals(4,h1.size());
|
||||||
void testSize() {
|
}
|
||||||
assertEquals(4,h1.size());
|
|
||||||
}
|
@Test
|
||||||
|
void testisEmpty() {
|
||||||
@Test
|
assertTrue(h1.isEmpty());
|
||||||
void testisEmpty() {
|
}
|
||||||
assertTrue(h1.isEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
package Timer;
|
package Timer;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class TimerKlasse extends TimerTask {
|
public class TimerKlasse extends TimerTask {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
TimerTask task = new TimerKlasse();
|
TimerTask task = new TimerKlasse();
|
||||||
|
|
||||||
timer.schedule(task,1000);
|
timer.schedule(task,5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
System.out.println("Hallo Welt!");
|
System.out.println("Hallo Welt!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,156 +1,174 @@
|
||||||
package TodoListApp.GUI_UserInterface;
|
package TodoListApp.GUI_UserInterface;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
|
|
||||||
import TodoListApp.Domain.*;
|
import TodoListApp.Domain.*;
|
||||||
|
|
||||||
public class GUI_addTask extends JFrame {
|
public class GUI_addTask extends JFrame {
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JTextField tasktitle;
|
private JTextField tasktitle;
|
||||||
private JTextField taskBeschreibung;
|
private JTextField taskBeschreibung;
|
||||||
private ButtonGroup priorityGroup;
|
private ButtonGroup priorityGroup;
|
||||||
private JButton submitTask;
|
private JButton submitTask;
|
||||||
private JRadioButton hoch, mittel,niedrig ;
|
private JRadioButton hoch, mittel,niedrig ;
|
||||||
|
|
||||||
public GUI_addTask() {
|
public GUI_addTask() {
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE );
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE );
|
||||||
setBounds(100, 100, 515, 618);
|
setBounds(100, 100, 515, 618);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBackground(new Color(255, 255, 255));
|
contentPane.setBackground(new Color(255, 255, 255));
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setBorder(new LineBorder(new Color(255, 255, 255), 3));
|
panel.setBorder(new LineBorder(new Color(255, 255, 255), 3));
|
||||||
panel.setBackground(new Color(0, 128, 255));
|
panel.setBackground(new Color(0, 128, 255));
|
||||||
panel.setForeground(new Color(255, 255, 255));
|
panel.setForeground(new Color(255, 255, 255));
|
||||||
panel.setBounds(31, 26, 441, 517);
|
panel.setBounds(31, 26, 441, 517);
|
||||||
contentPane.add(panel);
|
contentPane.add(panel);
|
||||||
panel.setLayout(null);
|
panel.setLayout(null);
|
||||||
|
|
||||||
JLabel lblNewLabel = new JLabel("Füge Task hinzu");
|
JLabel lblNewLabel = new JLabel("Füge Task hinzu");
|
||||||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 18));
|
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 18));
|
||||||
lblNewLabel.setForeground(new Color(255, 255, 255));
|
lblNewLabel.setForeground(new Color(255, 255, 255));
|
||||||
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
lblNewLabel.setBounds(76, 11, 289, 58);
|
lblNewLabel.setBounds(76, 11, 289, 58);
|
||||||
panel.add(lblNewLabel);
|
panel.add(lblNewLabel);
|
||||||
|
|
||||||
JLabel lblNewLabel_1 = new JLabel("Title:");
|
JLabel lblNewLabel_1 = new JLabel("Title:");
|
||||||
lblNewLabel_1.setForeground(new Color(255, 255, 255));
|
lblNewLabel_1.setForeground(new Color(255, 255, 255));
|
||||||
lblNewLabel_1.setHorizontalAlignment(SwingConstants.LEFT);
|
lblNewLabel_1.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 14));
|
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||||
lblNewLabel_1.setBounds(24, 79, 103, 14);
|
lblNewLabel_1.setBounds(24, 79, 103, 14);
|
||||||
panel.add(lblNewLabel_1);
|
panel.add(lblNewLabel_1);
|
||||||
|
|
||||||
JLabel lblNewLabel_1_1 = new JLabel("Beschreibung: ");
|
JLabel lblNewLabel_1_1 = new JLabel("Beschreibung: ");
|
||||||
lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.LEFT);
|
lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
lblNewLabel_1_1.setForeground(Color.WHITE);
|
lblNewLabel_1_1.setForeground(Color.WHITE);
|
||||||
lblNewLabel_1_1.setFont(new Font("Tahoma", Font.BOLD, 14));
|
lblNewLabel_1_1.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||||
lblNewLabel_1_1.setBounds(24, 121, 103, 14);
|
lblNewLabel_1_1.setBounds(24, 121, 103, 14);
|
||||||
panel.add(lblNewLabel_1_1);
|
panel.add(lblNewLabel_1_1);
|
||||||
|
|
||||||
JLabel lblNewLabel_1_3 = new JLabel("Priorität:");
|
JLabel lblNewLabel_1_3 = new JLabel("Priorität:");
|
||||||
lblNewLabel_1_3.setHorizontalAlignment(SwingConstants.LEFT);
|
lblNewLabel_1_3.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
lblNewLabel_1_3.setForeground(Color.WHITE);
|
lblNewLabel_1_3.setForeground(Color.WHITE);
|
||||||
lblNewLabel_1_3.setFont(new Font("Tahoma", Font.BOLD, 14));
|
lblNewLabel_1_3.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||||
lblNewLabel_1_3.setBounds(24, 203, 103, 14);
|
lblNewLabel_1_3.setBounds(24, 203, 103, 14);
|
||||||
panel.add(lblNewLabel_1_3);
|
panel.add(lblNewLabel_1_3);
|
||||||
|
|
||||||
tasktitle = new JTextField();
|
tasktitle = new JTextField();
|
||||||
tasktitle.setBounds(142, 77, 133, 20);
|
tasktitle.setBounds(142, 77, 133, 20);
|
||||||
panel.add(tasktitle);
|
panel.add(tasktitle);
|
||||||
tasktitle.setColumns(10);
|
tasktitle.setColumns(10);
|
||||||
|
|
||||||
taskBeschreibung = new JTextField();
|
taskBeschreibung = new JTextField();
|
||||||
taskBeschreibung.setColumns(10);
|
taskBeschreibung.setColumns(10);
|
||||||
taskBeschreibung.setBounds(142, 119, 133, 20);
|
taskBeschreibung.setBounds(142, 119, 133, 20);
|
||||||
panel.add(taskBeschreibung);
|
panel.add(taskBeschreibung);
|
||||||
|
|
||||||
// RadioButtons erstellen
|
// RadioButtons erstellen
|
||||||
hoch = new JRadioButton("Hoch");
|
hoch = new JRadioButton("Hoch");
|
||||||
hoch.setSelected(true);
|
hoch.setSelected(true);
|
||||||
hoch.setBounds(142, 165, 89, 23);
|
hoch.setBounds(142, 165, 89, 23);
|
||||||
panel.add(hoch);
|
panel.add(hoch);
|
||||||
|
|
||||||
mittel = new JRadioButton("Mittel");
|
mittel = new JRadioButton("Mittel");
|
||||||
mittel.setBounds(142, 201, 89, 23);
|
mittel.setBounds(142, 201, 89, 23);
|
||||||
panel.add(mittel);
|
panel.add(mittel);
|
||||||
|
|
||||||
niedrig = new JRadioButton("Niedrig");
|
niedrig = new JRadioButton("Niedrig");
|
||||||
niedrig.setBounds(142, 240, 89, 23);
|
niedrig.setBounds(142, 240, 89, 23);
|
||||||
panel.add(niedrig);
|
panel.add(niedrig);
|
||||||
|
|
||||||
// ButtonGroup erstellen, um die RadioButtons zu gruppieren
|
// ButtonGroup erstellen, um die RadioButtons zu gruppieren
|
||||||
priorityGroup = new ButtonGroup();
|
priorityGroup = new ButtonGroup();
|
||||||
priorityGroup.add(hoch);
|
priorityGroup.add(hoch);
|
||||||
priorityGroup.add(mittel);
|
priorityGroup.add(mittel);
|
||||||
priorityGroup.add(niedrig);
|
priorityGroup.add(niedrig);
|
||||||
|
|
||||||
submitTask = new JButton("Submit");
|
submitTask = new JButton("Submit");
|
||||||
submitTask.setBounds(24, 323, 123, 23);
|
submitTask.setBounds(24, 323, 123, 23);
|
||||||
panel.add(submitTask);
|
panel.add(submitTask);
|
||||||
setLocationRelativeTo(null);
|
|
||||||
}
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
scrollPane.setBounds(229, 333, 2, 2);
|
||||||
public void zeigeFensterAddTask() {
|
panel.add(scrollPane);
|
||||||
this.setVisible(true);
|
|
||||||
}
|
JCheckBox chckbxNewCheckBox = new JCheckBox("New check box");
|
||||||
|
chckbxNewCheckBox.setBounds(148, 383, 97, 23);
|
||||||
public void closeFensterAddTask() {
|
panel.add(chckbxNewCheckBox);
|
||||||
this.setVisible(false);
|
|
||||||
}
|
JButton resest = new JButton("Reset");
|
||||||
|
resest.setForeground(new Color(64, 0, 128));
|
||||||
public JTextField getTasktitle() {
|
resest.setFont(new Font("Microsoft Tai Le", Font.BOLD, 14));
|
||||||
return tasktitle;
|
resest.setBounds(221, 317, 144, 34);
|
||||||
}
|
panel.add(resest);
|
||||||
|
|
||||||
public void setTasktitle(JTextField tasktitle) {
|
JCheckBox chckbxNewCheckBox_1 = new JCheckBox("New check box");
|
||||||
this.tasktitle = tasktitle;
|
chckbxNewCheckBox_1.setBounds(268, 240, 112, 23);
|
||||||
}
|
panel.add(chckbxNewCheckBox_1);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
public JTextField getTaskBeschreibung() {
|
}
|
||||||
return taskBeschreibung;
|
|
||||||
}
|
public void zeigeFensterAddTask() {
|
||||||
|
this.setVisible(true);
|
||||||
public void setTaskBeschreibung(JTextField taskBeschreibung) {
|
}
|
||||||
this.taskBeschreibung = taskBeschreibung;
|
|
||||||
}
|
public void closeFensterAddTask() {
|
||||||
|
this.setVisible(false);
|
||||||
public ButtonGroup getPriorityGroup() {
|
}
|
||||||
return priorityGroup;
|
|
||||||
}
|
public JTextField getTasktitle() {
|
||||||
|
return tasktitle;
|
||||||
public JButton getSubmitTask() {
|
}
|
||||||
return submitTask;
|
|
||||||
}
|
public void setTasktitle(JTextField tasktitle) {
|
||||||
|
this.tasktitle = tasktitle;
|
||||||
public JRadioButton getHoch() {
|
}
|
||||||
return hoch;
|
|
||||||
}
|
public JTextField getTaskBeschreibung() {
|
||||||
|
return taskBeschreibung;
|
||||||
public JRadioButton getMittel() {
|
}
|
||||||
return mittel;
|
|
||||||
}
|
public void setTaskBeschreibung(JTextField taskBeschreibung) {
|
||||||
|
this.taskBeschreibung = taskBeschreibung;
|
||||||
public JRadioButton getNiedrig() {
|
}
|
||||||
return niedrig;
|
|
||||||
}
|
public ButtonGroup getPriorityGroup() {
|
||||||
|
return priorityGroup;
|
||||||
public void resetButtons() {
|
}
|
||||||
tasktitle.setText("");
|
|
||||||
taskBeschreibung.setText("");
|
public JButton getSubmitTask() {
|
||||||
hoch.setSelected(true);
|
return submitTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showInfo(String message) {
|
public JRadioButton getHoch() {
|
||||||
JOptionPane.showMessageDialog(null, message, "Studen angemeldet", JOptionPane.INFORMATION_MESSAGE);
|
return hoch;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public JRadioButton getMittel() {
|
||||||
|
return mittel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JRadioButton getNiedrig() {
|
||||||
|
return niedrig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetButtons() {
|
||||||
|
tasktitle.setText("");
|
||||||
|
taskBeschreibung.setText("");
|
||||||
|
hoch.setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showInfo(String message) {
|
||||||
|
JOptionPane.showMessageDialog(null, message, "Studen angemeldet", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,23 @@
|
||||||
package VorlesungsFolien.Verebung;
|
package VorlesungsFolien.Verebung;
|
||||||
|
|
||||||
public class A {
|
public class A {
|
||||||
|
|
||||||
void f() {
|
public void f() {
|
||||||
System.out.println("A");
|
System.out.println("A");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
A a1 = new A();
|
A a1 = new A();
|
||||||
A a2 = new B();
|
A a2 = new B();
|
||||||
B b = new B();
|
B b = new B();
|
||||||
|
|
||||||
a1.f();
|
a2.f();
|
||||||
// Ausgabe B:
|
}
|
||||||
// Das passiert aufgrund des Konzepts des Polymorphismus
|
}
|
||||||
// Dies liegt am Prinzip der dynamischen Bindung
|
|
||||||
a2.f();
|
class B extends A {
|
||||||
}
|
|
||||||
}
|
public void f() {
|
||||||
|
System.out.println("B");
|
||||||
class B extends A {
|
}
|
||||||
|
|
||||||
void f() {
|
|
||||||
System.out.println("B");
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,173 +1,173 @@
|
||||||
package VorlesungsFolien.Verebung;
|
package VorlesungsFolien.Verebung;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Firma {
|
public class Firma {
|
||||||
private ArrayList<Mitarbeiter> mas = new ArrayList<>();
|
private ArrayList<Mitarbeiter> mas = new ArrayList<>();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Mitarbeiter mi = new Manager("Stromberg", "01.02.1970", "Finanzen");
|
Mitarbeiter mi = new Manager("Stromberg", "01.02.1970", "Finanzen");
|
||||||
Manager ma = new Geschaeftsfuehrer();
|
Manager ma = new Geschaeftsfuehrer();
|
||||||
Mitarbeiter m = new Geschaeftsfuehrer();
|
Mitarbeiter m = new Geschaeftsfuehrer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Ja weil Manager ein Mitarbeiter ist
|
// Ja weil Manager ein Mitarbeiter ist
|
||||||
if (mi instanceof Mitarbeiter )
|
if (mi instanceof Mitarbeiter )
|
||||||
System.out.println("Ja ");
|
System.out.println("Ja ");
|
||||||
|
|
||||||
// Ja weil Manager ein Manager ist
|
// Ja weil Manager ein Manager ist
|
||||||
if (mi instanceof Manager )
|
if (mi instanceof Manager )
|
||||||
System.out.println("Ja stimmt");
|
System.out.println("Ja stimmt");
|
||||||
|
|
||||||
// nein, weil nicht jeder manager ein Geschaeftsfuehrer ist, aber jeder Geschaeftsfuehrer ist ein manager
|
// nein, weil nicht jeder manager ein Geschaeftsfuehrer ist, aber jeder Geschaeftsfuehrer ist ein manager
|
||||||
if (mi instanceof Geschaeftsfuehrer)
|
if (mi instanceof Geschaeftsfuehrer)
|
||||||
System.out.println("Ja");
|
System.out.println("Jalll");
|
||||||
|
|
||||||
if (null instanceof Geschaeftsfuehrer )
|
if (null instanceof Geschaeftsfuehrer )
|
||||||
System.out.println("null");
|
System.out.println("null");
|
||||||
|
|
||||||
if (null instanceof Mitarbeiter )
|
if (null instanceof Mitarbeiter )
|
||||||
System.out.println("null");
|
System.out.println("null");
|
||||||
|
|
||||||
if (null instanceof Manager )
|
if (null instanceof Manager )
|
||||||
System.out.println("null");
|
System.out.println("null");
|
||||||
|
|
||||||
if (ma instanceof Geschaeftsfuehrer)
|
if (ma instanceof Geschaeftsfuehrer)
|
||||||
System.out.println("Ja");
|
System.out.println("Ja");
|
||||||
|
|
||||||
mi = ma;
|
mi = ma;
|
||||||
|
|
||||||
//ma = mi; nein, weil nicht jeder mitarbeiter ein manager ist!
|
//ma = mi; nein, weil nicht jeder mitarbeiter ein manager ist!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Firma firma = new Firma();
|
Firma firma = new Firma();
|
||||||
Mitarbeiter mitarbeiter2 = new Mitarbeiter("Mayer", "12.12.1999");
|
Mitarbeiter mitarbeiter2 = new Mitarbeiter("Mayer", "12.12.1999");
|
||||||
Mitarbeiter mitarbeiter = new Mitarbeiter("Müller", "27.10.1972");
|
Mitarbeiter mitarbeiter = new Mitarbeiter("Müller", "27.10.1972");
|
||||||
Manager manager = new Manager("Stromberg", "01.02.1970", "Finanzen");
|
Manager manager = new Manager("Stromberg", "01.02.1970", "Finanzen");
|
||||||
firma.mitarbeiterEinstellen(mitarbeiter);
|
firma.mitarbeiterEinstellen(mitarbeiter);
|
||||||
firma.mitarbeiterEinstellen(manager);
|
firma.mitarbeiterEinstellen(manager);
|
||||||
|
|
||||||
|
|
||||||
firma.mitarbeiterEinstellen(mitarbeiter2);
|
firma.mitarbeiterEinstellen(mitarbeiter2);
|
||||||
|
|
||||||
/* geht nicht! Warum?
|
/* geht nicht! Warum?
|
||||||
* weil nicht jeder mitarbeiter ein manager ist!
|
* weil nicht jeder mitarbeiter ein manager ist!
|
||||||
*/
|
*/
|
||||||
// manager = mitarbeiter; //geht nicht!
|
// manager = mitarbeiter; //geht nicht!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//weil jeder manager ist ein mitarbeiter
|
//weil jeder manager ist ein mitarbeiter
|
||||||
// mitarbeiter = manager;// Ja geht:
|
// mitarbeiter = manager;// Ja geht:
|
||||||
System.out.println("Polymorphismus");
|
System.out.println("Polymorphismus");
|
||||||
System.out.println(mitarbeiter.getGehalt());
|
System.out.println(mitarbeiter.getGehalt());
|
||||||
System.out.println(manager.getAbteilung());
|
System.out.println(manager.getAbteilung());
|
||||||
// System.out.println(mitarbeiter.getAbteilung()); // geht nicht, wg. statischem Typ Mitarbeiter
|
// System.out.println(mitarbeiter.getAbteilung()); // geht nicht, wg. statischem Typ Mitarbeiter
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Geht ");
|
System.out.println("Geht ");
|
||||||
|
|
||||||
Manager me = ((Manager)mitarbeiter);
|
Manager me = ((Manager)mitarbeiter);
|
||||||
|
|
||||||
// mitarbeiter2 = manager;// Ja geht:
|
// mitarbeiter2 = manager;// Ja geht:
|
||||||
Manager md =((Manager)mitarbeiter2);
|
Manager md =((Manager)mitarbeiter2);
|
||||||
|
|
||||||
// ClassCastException zur laufzeit, weil ich if (mitarbeiter instanceof Manager) verwenden soll
|
// ClassCastException zur laufzeit, weil ich if (mitarbeiter instanceof Manager) verwenden soll
|
||||||
|
|
||||||
|
|
||||||
// WICHTIG:
|
// WICHTIG:
|
||||||
//instanceof prüft, ob die klasse manager die klasse mitarbeiter erbt
|
//instanceof prüft, ob die klasse manager die klasse mitarbeiter erbt
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mitarbeiterEinstellen(Mitarbeiter m) {
|
private void mitarbeiterEinstellen(Mitarbeiter m) {
|
||||||
mas.add(m);
|
mas.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gehaltsErhöhung() {
|
private void gehaltsErhöhung() {
|
||||||
for (Mitarbeiter m : mas) {
|
for (Mitarbeiter m : mas) {
|
||||||
double erhöhung = 0.02;
|
double erhöhung = 0.02;
|
||||||
|
|
||||||
// System.out.println(m instanceof String); // das geht NICHT, muss zur Vererbungshierachie passen
|
// System.out.println(m instanceof String); // das geht NICHT, muss zur Vererbungshierachie passen
|
||||||
|
|
||||||
if (m instanceof Manager)
|
if (m instanceof Manager)
|
||||||
erhöhung = 0.12;
|
erhöhung = 0.12;
|
||||||
// else if (m instanceof Geschäftsführer)
|
// else if (m instanceof Geschäftsführer)
|
||||||
// erhöhung = 0.2;
|
// erhöhung = 0.2;
|
||||||
|
|
||||||
m.setGehalt(m.getGehalt() * (1 + erhöhung));
|
m.setGehalt(m.getGehalt() * (1 + erhöhung));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Mitarbeiter extends Object {
|
class Mitarbeiter extends Object {
|
||||||
private String name;
|
private String name;
|
||||||
private double gehalt;
|
private double gehalt;
|
||||||
private String geburtsdatum;
|
private String geburtsdatum;
|
||||||
|
|
||||||
public Mitarbeiter(String name, String geburtsdatum) {
|
public Mitarbeiter(String name, String geburtsdatum) {
|
||||||
this(name, 35000, geburtsdatum);
|
this(name, 35000, geburtsdatum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mitarbeiter(String name, double gehalt, String geburtsdatum) {
|
public Mitarbeiter(String name, double gehalt, String geburtsdatum) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.gehalt = gehalt;
|
this.gehalt = gehalt;
|
||||||
this.geburtsdatum = geburtsdatum;
|
this.geburtsdatum = geburtsdatum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mitarbeiter() {
|
public Mitarbeiter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetails() {
|
public String getDetails() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGehalt() {
|
public double getGehalt() {
|
||||||
return gehalt;
|
return gehalt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGehalt(double gehalt) {
|
public void setGehalt(double gehalt) {
|
||||||
this.gehalt = gehalt;
|
this.gehalt = gehalt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Manager extends Mitarbeiter {
|
class Manager extends Mitarbeiter {
|
||||||
private String abteilung;
|
private String abteilung;
|
||||||
|
|
||||||
public Manager(String name, String geburtsdatum, String abteilung) {
|
public Manager(String name, String geburtsdatum, String abteilung) {
|
||||||
super(name, 65000, geburtsdatum); // das MUSS zuerst gemacht werden!
|
super(name, 65000, geburtsdatum); // das MUSS zuerst gemacht werden!
|
||||||
this.abteilung = abteilung;
|
this.abteilung = abteilung;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Manager() {
|
public Manager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDetails() {
|
public String getDetails() {
|
||||||
return super.getDetails() + " " + abteilung;
|
return super.getDetails() + " " + abteilung;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbteilung() {
|
public String getAbteilung() {
|
||||||
return abteilung;
|
return abteilung;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Geschaeftsfuehrer extends Manager{
|
class Geschaeftsfuehrer extends Manager{
|
||||||
|
|
||||||
public Geschaeftsfuehrer(String name, String geburtsdatum, String abteilung) {
|
public Geschaeftsfuehrer(String name, String geburtsdatum, String abteilung) {
|
||||||
super(name, geburtsdatum, abteilung);
|
super(name, geburtsdatum, abteilung);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Geschaeftsfuehrer(){
|
public Geschaeftsfuehrer(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printGeschaeftsfuehrer() {
|
public void printGeschaeftsfuehrer() {
|
||||||
System.out.println("Hi");
|
System.out.println("Hi");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
module Programmierung2 {
|
module Programmierung2 {
|
||||||
requires java.desktop;
|
requires java.desktop;
|
||||||
requires org.junit.jupiter.api;
|
requires org.junit.jupiter.api;
|
||||||
requires junit;
|
|
||||||
requires java.sql;
|
requires java.sql;
|
||||||
requires java.logging;
|
requires java.logging;
|
||||||
exports Übungen.TaschenrechnerGUI to junit; // Exportiere das Paket für das JUnit-Modul
|
|
||||||
}
|
}
|
Binary file not shown.
|
@ -1,39 +1,39 @@
|
||||||
package oop.Generics;
|
package oop.Generics;
|
||||||
|
|
||||||
public class Pocket<T> {
|
import java.util.*;
|
||||||
|
|
||||||
private T value;
|
public class Pocket<T> {
|
||||||
public Pocket() {}
|
|
||||||
|
private T value;
|
||||||
public Pocket(T value) {
|
public Pocket() {}
|
||||||
this.value = value;
|
|
||||||
}
|
public Pocket(T value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
public T getValue() {
|
|
||||||
return value;
|
public static <G> G getT(G g) {
|
||||||
}
|
return g;
|
||||||
|
}
|
||||||
public void setValue(T value) {
|
|
||||||
this.value = value;
|
public T getValue() {
|
||||||
}
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void setValue(T value) {
|
||||||
public String toString() {
|
this.value = value;
|
||||||
return "Pocket [value=" + value + "]";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public static void main(String[] args) {
|
public String toString() {
|
||||||
Pocket<Pocket<String>> pocketOfPockets = new Pocket<>();
|
return "Pocket [value=" + value + "]";
|
||||||
pocketOfPockets.setValue(new Pocket<String>());
|
}
|
||||||
pocketOfPockets.getValue().setValue("Innere Pocket");
|
|
||||||
System.out.println(pocketOfPockets.getValue().getValue());
|
|
||||||
//-----------------------------------------------------------------
|
public static void main(String[] args) {
|
||||||
Pocket<String>[] pocket = new Pocket[10]; // mit 10 Plätzen
|
List<Object> stringList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package oop.Generics;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class RawType{
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ArrayList<Integer> t = new ArrayList<>();
|
||||||
|
t.add(22);
|
||||||
|
t.add(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printList(ArrayList<Object> list) {
|
||||||
|
for (Object elem : list)
|
||||||
|
System.out.println(elem + " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,45 +1,17 @@
|
||||||
package streams;
|
package streams;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.stream.*;
|
import java.util.stream.*;
|
||||||
|
|
||||||
public class Beispiele {
|
public class Beispiele {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Integer[] myArray = new Integer[] { 10, 20, 22, 30, 50 };
|
|
||||||
Stream<Integer> myStream = Arrays.stream(myArray);
|
|
||||||
/*
|
int[] array = { 1, 2, 3, 45, 6 };
|
||||||
* Hier macht der Stream nichts, weil die Intermediate-Operation filter keine
|
IntStream.of(array).forEach(System.out::print);
|
||||||
* Aktion auslöst, solange keine Terminal-Operation aufgerufen wird.
|
|
||||||
*/
|
}
|
||||||
// myStream.filter(i -> (i % 2 == 0));//Keine Wirkung, da keine Terminal-Operation folgt
|
|
||||||
|
|
||||||
/*
|
}
|
||||||
* Hier wird eine Intermediate-Operation (filter) auf dem Stream aufgerufen, die
|
|
||||||
* die geraden Zahlen aus dem Stream herausfiltert. Danach wird die
|
|
||||||
* Terminal-Operation count() aufgerufen, die die Anzahl der gefilterten
|
|
||||||
* Elemente zählt und als long zurückgibt.
|
|
||||||
*/
|
|
||||||
long x = myStream.filter(i -> (i % 2 == 0)).count(); // count gibt Long zurück
|
|
||||||
System.out.println(x);
|
|
||||||
|
|
||||||
// Wiederverwendung von myStream liefert einen Compiler-Fehler, da der Stream
|
|
||||||
// bereits abgeschlossen ist.
|
|
||||||
// Ein Stream kann nur einmal verwendet werden, und nach einer
|
|
||||||
// Terminal-Operation wie count()
|
|
||||||
// ist der Stream geschlossen und nicht wiederverwendbar.
|
|
||||||
x = myStream.filter(i -> (i % 2 == 1)).count(); // Compiler-Fehler
|
|
||||||
System.out.println(x);
|
|
||||||
|
|
||||||
// Compiler-Fehler: Stream has already been operated upon or closed
|
|
||||||
// Dieser Fehler tritt auf, weil myStream nach der ersten count()-Operation
|
|
||||||
// nicht erneut verwendet werden kann.
|
|
||||||
long y = myStream.filter(i -> (i % 2 == 1)).count(); // Compiler-Fehler
|
|
||||||
System.out.println(y);
|
|
||||||
|
|
||||||
int[] array = { 1, 2, 3, 45, 6 };
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package Übungen.BlackJack;
|
package Übungen.BlackJack;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
package Übungen.MyBankSystem;
|
package Übungen.MyBankSystem;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
//class JTest {
|
//class JTest {
|
||||||
// private Konto obaiKonto1;
|
// private Konto obaiKonto1;
|
||||||
// private Konto obaiKonto2;
|
// private Konto obaiKonto2;
|
||||||
// private User obai;
|
// private User obai;
|
||||||
//
|
//
|
||||||
// @BeforeEach
|
// @BeforeEach
|
||||||
// void erstelleObjekt() {
|
// void erstelleObjekt() {
|
||||||
// obai = new User("Obai" , "123");
|
// obai = new User("Obai" , "123");
|
||||||
// obaiKonto1 = new Konto(1234,0,obai);
|
// obaiKonto1 = new Konto(1234,0,obai);
|
||||||
// obaiKonto2 = new Konto (1235,0 ,obai);
|
// obaiKonto2 = new Konto (1235,0 ,obai);
|
||||||
// obai.addKonto(obaiKonto1);
|
// obai.addKonto(obaiKonto1);
|
||||||
// obai.addKonto(obaiKonto2);
|
// obai.addKonto(obaiKonto2);
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// @Disabled
|
// @Disabled
|
||||||
// void testEinzahlen() throws Exception {
|
// void testEinzahlen() throws Exception {
|
||||||
// obai.einzahlen(123, obaiKonto1);
|
// obai.einzahlen(123, obaiKonto1);
|
||||||
// obai.einzahlen(124, obaiKonto2);
|
// obai.einzahlen(124, obaiKonto2);
|
||||||
// assertEquals(123,obaiKonto1.getKontostand());
|
// assertEquals(123,obaiKonto1.getKontostand());
|
||||||
// assertEquals(124,obaiKonto2.getKontostand());
|
// assertEquals(124,obaiKonto2.getKontostand());
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Test
|
// @Test
|
||||||
// void testauszahlen() throws Exception {
|
// void testauszahlen() throws Exception {
|
||||||
// obai.einzahlen(123, obaiKonto1);
|
// obai.einzahlen(123, obaiKonto1);
|
||||||
// obai.auszahlen(123, obaiKonto1);
|
// obai.auszahlen(123, obaiKonto1);
|
||||||
// assertEquals(0,obaiKonto1.getKontostand());
|
// assertEquals(0,obaiKonto1.getKontostand());
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @Test
|
// @Test
|
||||||
// void testueberweisen() throws Exception {
|
// void testueberweisen() throws Exception {
|
||||||
// obai.einzahlen(123, obaiKonto1);
|
// obai.einzahlen(123, obaiKonto1);
|
||||||
// obai.ueberweisen(100, obaiKonto1, obaiKonto2);
|
// obai.ueberweisen(100, obaiKonto1, obaiKonto2);
|
||||||
//
|
//
|
||||||
// assertEquals(23,obaiKonto1.getKontostand());
|
// assertEquals(23,obaiKonto1.getKontostand());
|
||||||
// assertEquals(100,obaiKonto2.getKontostand());
|
// assertEquals(100,obaiKonto2.getKontostand());
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -1,115 +1,61 @@
|
||||||
package Übungen;
|
package Übungen;
|
||||||
|
import javax.swing.*;
|
||||||
import java.awt.EventQueue;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.*;
|
||||||
import javax.swing.*;
|
import java.util.ArrayList;
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
import java.awt.*;
|
public class Stopuhr extends JFrame {
|
||||||
import java.util.ArrayList;
|
|
||||||
|
JPanel contentPane;
|
||||||
public class Stopuhr extends JFrame {
|
JLabel zeige_zeit;
|
||||||
|
JButton start_zeit;
|
||||||
JPanel contentPane;
|
Timer timer;
|
||||||
JLabel zeige_zeit;
|
long startzeit;
|
||||||
JButton start_zeit, stop_zeit_1;
|
|
||||||
JTextArea zeige_alleZeiten;
|
public Stopuhr() {
|
||||||
|
this.setTitle("Stopuhr");
|
||||||
Timer timer, print_alleZeiten;
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
boolean aktiv;
|
setBounds(100, 100, 498, 630);
|
||||||
long startzeit;
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
int speichere_alle_zeiten_index = 0;
|
setContentPane(contentPane);
|
||||||
ArrayList<String> speichere_alle_zeiten = new ArrayList<>();
|
contentPane.setLayout(null);
|
||||||
|
zeite_elemente();
|
||||||
public Stopuhr() {
|
start_programm();
|
||||||
this.setTitle("Stopuhr");
|
this.setVisible(true);
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
}
|
||||||
setBounds(100, 100, 498, 630);
|
|
||||||
contentPane = new JPanel();
|
public void start_programm() {
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
timer = new Timer(1000, e -> update_zeit());
|
||||||
setContentPane(contentPane);
|
start_zeit.addActionListener(e -> start_stopuhr());
|
||||||
contentPane.setLayout(null);
|
}
|
||||||
zeite_elemente();
|
|
||||||
start_programm();
|
public void start_stopuhr() {
|
||||||
|
timer.start();
|
||||||
|
startzeit = System.currentTimeMillis(); // Milisekunden
|
||||||
this.setVisible(true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void start_programm() {
|
public void update_zeit() {
|
||||||
aktiv = false;
|
double rest = (System.currentTimeMillis() - startzeit) / 1000.0;
|
||||||
timer = new Timer(100, e -> update_zeit());
|
String formatiere_zahl = String.format("Zeit: %.1f s", rest);
|
||||||
print_alleZeiten = new Timer(100, e -> print_next_time());
|
zeige_zeit.setText(formatiere_zahl);
|
||||||
start_zeit.addActionListener(e -> start_stopuhr());
|
System.out.println(formatiere_zahl);
|
||||||
stop_zeit_1.addActionListener(e -> stop_stopuhr());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void start_stopuhr() {
|
|
||||||
if (!aktiv) {
|
public static void main(String[] args) {
|
||||||
timer.start();
|
new Stopuhr();
|
||||||
startzeit = System.currentTimeMillis(); // Milisekunden
|
}
|
||||||
aktiv = true;
|
|
||||||
speichere_alle_zeiten_index = 0;
|
public void zeite_elemente() {
|
||||||
|
zeige_zeit = new JLabel("Zeit: 0.0 s");
|
||||||
}else
|
zeige_zeit.setFont(new Font("Tahoma", Font.BOLD, 16));
|
||||||
print_alleZeiten.start();
|
zeige_zeit.setBounds(10, 11, 450, 42);
|
||||||
|
contentPane.add(zeige_zeit);
|
||||||
|
start_zeit = new JButton("Start/Lap");
|
||||||
}
|
start_zeit.setBounds(10, 484, 190, 54);
|
||||||
|
contentPane.add(start_zeit);
|
||||||
public void stop_stopuhr() {
|
}
|
||||||
if (aktiv) {
|
|
||||||
timer.stop();
|
|
||||||
print_alleZeiten.stop();
|
|
||||||
start_zeit.setEnabled(false);
|
|
||||||
aktiv = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
zeige_alleZeiten.setText("");
|
|
||||||
zeige_zeit.setText("Zeit: 0.0 s");
|
|
||||||
start_zeit.setEnabled(true);
|
|
||||||
speichere_alle_zeiten.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update_zeit() {
|
|
||||||
double rest = (System.currentTimeMillis() - startzeit) / 1000.0;
|
|
||||||
String formatiere_zahl = String.format("Zeit: %.1f s", rest);
|
|
||||||
speichere_alle_zeiten.add(formatiere_zahl);
|
|
||||||
zeige_zeit.setText(formatiere_zahl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void print_next_time() {
|
|
||||||
|
|
||||||
zeige_alleZeiten.append(speichere_alle_zeiten_index + 1 + ".: " + speichere_alle_zeiten.get(speichere_alle_zeiten_index) + "\n");
|
|
||||||
speichere_alle_zeiten_index++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new Stopuhr();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getalleZeiten() {
|
|
||||||
return speichere_alle_zeiten;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void zeite_elemente() {
|
|
||||||
zeige_zeit = new JLabel("Zeit: 0.0 s");
|
|
||||||
zeige_zeit.setFont(new Font("Tahoma", Font.BOLD, 16));
|
|
||||||
zeige_zeit.setBounds(10, 11, 450, 42);
|
|
||||||
contentPane.add(zeige_zeit);
|
|
||||||
start_zeit = new JButton("Start/Lap");
|
|
||||||
start_zeit.setBounds(10, 484, 190, 54);
|
|
||||||
contentPane.add(start_zeit);
|
|
||||||
|
|
||||||
stop_zeit_1 = new JButton("Stop/Löschen");
|
|
||||||
stop_zeit_1.setBounds(252, 484, 190, 54);
|
|
||||||
contentPane.add(stop_zeit_1);
|
|
||||||
|
|
||||||
zeige_alleZeiten = new JTextArea();
|
|
||||||
zeige_alleZeiten.setFont(new Font("Arial", Font.BOLD, 15));
|
|
||||||
zeige_alleZeiten.setBounds(10, 53, 417, 376);
|
|
||||||
contentPane.add(zeige_alleZeiten);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,46 +1,45 @@
|
||||||
package Übungen.TaschenrechnerGUI;
|
package Übungen.TaschenrechnerGUI;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
|
public class JunitTest {
|
||||||
public class JunitTest {
|
// Modell<?, ?> m1;
|
||||||
// Modell<?, ?> m1;
|
//
|
||||||
//
|
// @BeforeEach
|
||||||
// @BeforeEach
|
// public void initi() {
|
||||||
// public void initi() {
|
// m1 = new Modell<>();
|
||||||
// m1 = new Modell<>();
|
// }
|
||||||
// }
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testAdd() {
|
||||||
public void testAdd() {
|
Modell<Integer, Integer> m1 = new Modell<>();
|
||||||
Modell<Integer, Integer> m1 = new Modell<>();
|
assertEquals(15 ,m1.add(10, 5).intValue());
|
||||||
assertEquals(15 ,m1.add(10, 5).intValue());
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@Disabled
|
||||||
@Disabled
|
public void testSub() {
|
||||||
public void testSub() {
|
Modell<Integer, Integer> m1 = new Modell<>();
|
||||||
Modell<Integer, Integer> m1 = new Modell<>();
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@Disabled
|
||||||
@Disabled
|
public void testmulti() {
|
||||||
public void testmulti() {
|
Modell<Double, Double> m1 = new Modell<>();
|
||||||
Modell<Double, Double> m1 = new Modell<>();
|
assertEquals(1.44 ,m1.multi(1.2, 1.2).doubleValue());
|
||||||
assertEquals(1.44 ,m1.multi(1.2, 1.2).doubleValue());
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@Disabled
|
||||||
@Disabled
|
public void testdivid() {
|
||||||
public void testdivid() {
|
Modell<Integer, Integer> m1 = new Modell<>();
|
||||||
Modell<Integer, Integer> m1 = new Modell<>();
|
assertEquals(1 ,m1.divid(5, 5).intValue());
|
||||||
assertEquals(1 ,m1.divid(5, 5).intValue());
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,156 +1,158 @@
|
||||||
package Übungen.TaschenrechnerGUI;
|
package Übungen.TaschenrechnerGUI;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class View extends JFrame {
|
public class View extends JFrame {
|
||||||
// Fenster Eigenschaften:
|
// Fenster Eigenschaften:
|
||||||
final int WIDTH = 500;
|
final int WIDTH = 500;
|
||||||
final int HEIGHT = 500;
|
final int HEIGHT = 500;
|
||||||
|
|
||||||
// Fenster Elemente:
|
// Fenster Elemente:
|
||||||
JTextField eingabe = new JTextField();
|
JTextField eingabe = new JTextField();
|
||||||
JLabel ergebnisse = new JLabel();
|
JLabel ergebnisse = new JLabel();
|
||||||
JLabel error = new JLabel();
|
JLabel error = new JLabel();
|
||||||
|
|
||||||
JButton button1 = new JButton("1");
|
JButton button1 = new JButton("1");
|
||||||
JButton button2 = new JButton("2");
|
JButton button2 = new JButton("2");
|
||||||
JButton button3 = new JButton("3");
|
JButton button3 = new JButton("3");
|
||||||
JButton button4 = new JButton("4");
|
JButton button4 = new JButton("4");
|
||||||
JButton button5 = new JButton("5");
|
JButton button5 = new JButton("5");
|
||||||
JButton button6 = new JButton("6");
|
JButton button6 = new JButton("6");
|
||||||
JButton button7 = new JButton("7");
|
JButton button7 = new JButton("7");
|
||||||
JButton button8 = new JButton("8");
|
JButton button8 = new JButton("8");
|
||||||
JButton button9 = new JButton("9");
|
JButton button9 = new JButton("9");
|
||||||
JButton button0 = new JButton("0");
|
JButton button0 = new JButton("0");
|
||||||
JButton plus = new JButton("+");
|
JButton plus = new JButton("+");
|
||||||
JButton minus = new JButton("-");
|
JButton minus = new JButton("-");
|
||||||
JButton multi = new JButton("x");
|
JButton multi = new JButton("x");
|
||||||
JButton divid = new JButton("÷");
|
JButton divid = new JButton("÷");
|
||||||
JButton punkt = new JButton(".");
|
JButton punkt = new JButton(".");
|
||||||
JButton berechnen = new JButton("=");
|
JButton berechnen = new JButton("=");
|
||||||
JButton clear = new JButton("C");
|
JButton clear = new JButton("C");
|
||||||
JButton back = new JButton("←");
|
JButton back = new JButton("←");
|
||||||
|
|
||||||
int buttonWidth = 60;
|
int buttonWidth = 60;
|
||||||
int buttonheight = 30;
|
int buttonheight = 30;
|
||||||
|
|
||||||
|
|
||||||
public View() {
|
public View() {
|
||||||
this.setTitle("Taschenrechner");
|
this.setTitle("Taschenrechner");
|
||||||
this.setSize(WIDTH, HEIGHT);
|
this.setSize(WIDTH, HEIGHT);
|
||||||
this.setResizable(false);
|
this.setResizable(false);
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.setLayout(null);
|
getContentPane().setLayout(null);
|
||||||
|
|
||||||
ergebnisse.setBounds(40, 60, 300, 40);
|
ergebnisse.setBounds(40, 60, 300, 40);
|
||||||
error.setBounds(40, 60, 100, 30);
|
error.setBounds(40, 60, 100, 30);
|
||||||
eingabe.setBounds(40, 100, buttonWidth * 6 + 20, 40);
|
eingabe.setBounds(40, 100, buttonWidth * 6 + 20, 40);
|
||||||
button1.setBounds(40,150,buttonWidth,buttonheight);
|
button1.setBounds(40,150,buttonWidth,buttonheight);
|
||||||
button2.setBounds(120,150,buttonWidth,buttonheight);
|
button2.setBounds(120,150,buttonWidth,buttonheight);
|
||||||
button3.setBounds(200,150,buttonWidth,buttonheight);
|
button3.setBounds(200,150,buttonWidth,buttonheight);
|
||||||
button4.setBounds(40,190,buttonWidth,buttonheight);
|
button4.setBounds(40,190,buttonWidth,buttonheight);
|
||||||
button5.setBounds(120,190,buttonWidth,buttonheight);
|
button5.setBounds(120,190,buttonWidth,buttonheight);
|
||||||
button6.setBounds(200,190,buttonWidth,buttonheight);
|
button6.setBounds(200,190,buttonWidth,buttonheight);
|
||||||
button7.setBounds(40,230,buttonWidth,buttonheight);
|
button7.setBounds(40,230,buttonWidth,buttonheight);
|
||||||
button8.setBounds(120,230,buttonWidth,buttonheight);
|
button8.setBackground(new Color(0, 64, 0));
|
||||||
button9.setBounds(200,230,buttonWidth,buttonheight);
|
button8.setForeground(new Color(0, 64, 0));
|
||||||
button0.setBounds(40,270,buttonWidth*2 + 20,buttonheight);
|
button8.setBounds(120,230,buttonWidth,buttonheight);
|
||||||
punkt.setBounds(200, 270, buttonWidth, buttonheight);
|
button9.setBounds(200,230,buttonWidth,buttonheight);
|
||||||
|
button0.setBounds(40,270,buttonWidth*2 + 20,buttonheight);
|
||||||
plus.setBounds(280, 150, buttonWidth, buttonheight);
|
punkt.setBounds(200, 270, buttonWidth, buttonheight);
|
||||||
plus.setBackground(Color.GRAY);
|
|
||||||
plus.setForeground(Color.WHITE);
|
plus.setBounds(280, 150, buttonWidth, buttonheight);
|
||||||
minus.setBounds(280, 190, buttonWidth, buttonheight);
|
plus.setBackground(Color.GRAY);
|
||||||
minus.setBackground(Color.GRAY);
|
plus.setForeground(Color.WHITE);
|
||||||
minus.setForeground(Color.WHITE);
|
minus.setBounds(280, 190, buttonWidth, buttonheight);
|
||||||
multi.setBounds(280, 230, buttonWidth, buttonheight);
|
minus.setBackground(Color.GRAY);
|
||||||
multi.setBackground(Color.GRAY);
|
minus.setForeground(Color.WHITE);
|
||||||
multi.setForeground(Color.WHITE);
|
multi.setBounds(280, 230, buttonWidth, buttonheight);
|
||||||
divid.setBounds(280, 270, buttonWidth, buttonheight);
|
multi.setBackground(Color.GRAY);
|
||||||
divid.setBackground(Color.GRAY);
|
multi.setForeground(Color.WHITE);
|
||||||
divid.setForeground(Color.WHITE);
|
divid.setBounds(280, 270, buttonWidth, buttonheight);
|
||||||
|
divid.setBackground(Color.GRAY);
|
||||||
|
divid.setForeground(Color.WHITE);
|
||||||
|
|
||||||
clear.setBackground(Color.RED);
|
|
||||||
clear.setForeground(Color.white);
|
|
||||||
clear.setBounds(360,150 , buttonWidth, buttonheight);
|
clear.setBackground(Color.RED);
|
||||||
|
clear.setForeground(Color.white);
|
||||||
back.setBackground(Color.ORANGE);
|
clear.setBounds(360,150 , buttonWidth, buttonheight);
|
||||||
back.setForeground(Color.white);
|
|
||||||
back.setBounds(360,190, buttonWidth, buttonheight);
|
back.setBackground(Color.ORANGE);
|
||||||
|
back.setForeground(Color.white);
|
||||||
berechnen.setBackground(Color.GRAY);
|
back.setBounds(360,190, buttonWidth, buttonheight);
|
||||||
berechnen.setForeground(Color.WHITE);
|
|
||||||
berechnen.setBounds(360, 230, buttonWidth, buttonheight* 2 + 10);
|
berechnen.setBackground(Color.GRAY);
|
||||||
|
berechnen.setForeground(Color.WHITE);
|
||||||
this.add(clear);
|
berechnen.setBounds(360, 230, buttonWidth, buttonheight* 2 + 10);
|
||||||
this.add(error);
|
|
||||||
this.add(ergebnisse);
|
getContentPane().add(clear);
|
||||||
this.add(eingabe);
|
getContentPane().add(error);
|
||||||
this.add(button1);
|
getContentPane().add(ergebnisse);
|
||||||
this.add(button2);
|
getContentPane().add(eingabe);
|
||||||
this.add(button3);
|
getContentPane().add(button1);
|
||||||
this.add(button4);
|
getContentPane().add(button2);
|
||||||
this.add(button5);
|
getContentPane().add(button3);
|
||||||
this.add(button6);
|
getContentPane().add(button4);
|
||||||
this.add(button7);
|
getContentPane().add(button5);
|
||||||
this.add(button8);
|
getContentPane().add(button6);
|
||||||
this.add(button9);
|
getContentPane().add(button7);
|
||||||
this.add(button0);
|
getContentPane().add(button8);
|
||||||
this.add(punkt);
|
getContentPane().add(button9);
|
||||||
this.add(plus);
|
getContentPane().add(button0);
|
||||||
this.add(minus);
|
getContentPane().add(punkt);
|
||||||
this.add(multi);
|
getContentPane().add(plus);
|
||||||
this.add(divid);
|
getContentPane().add(minus);
|
||||||
this.add(berechnen);
|
getContentPane().add(multi);
|
||||||
this.add(back);
|
getContentPane().add(divid);
|
||||||
|
getContentPane().add(berechnen);
|
||||||
}
|
getContentPane().add(back);
|
||||||
|
|
||||||
public void updateErgebnisse(String erg) {
|
}
|
||||||
ergebnisse.setText(erg);
|
|
||||||
}
|
public void updateErgebnisse(String erg) {
|
||||||
|
ergebnisse.setText(erg);
|
||||||
public void showError(String err) {
|
}
|
||||||
ergebnisse.setText(err);
|
|
||||||
}
|
public void showError(String err) {
|
||||||
|
ergebnisse.setText(err);
|
||||||
public void setEingabe(String auswahl) {
|
}
|
||||||
eingabe.setText(auswahl);
|
|
||||||
}
|
public void setEingabe(String auswahl) {
|
||||||
|
eingabe.setText(auswahl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setAction(ActionListener actionListener) {
|
|
||||||
button1.addActionListener(actionListener);
|
|
||||||
button2.addActionListener(actionListener);
|
public void setAction(ActionListener actionListener) {
|
||||||
button3.addActionListener(actionListener);
|
button1.addActionListener(actionListener);
|
||||||
button4.addActionListener(actionListener);
|
button2.addActionListener(actionListener);
|
||||||
button5.addActionListener(actionListener);
|
button3.addActionListener(actionListener);
|
||||||
button6.addActionListener(actionListener);
|
button4.addActionListener(actionListener);
|
||||||
button7.addActionListener(actionListener);
|
button5.addActionListener(actionListener);
|
||||||
button8.addActionListener(actionListener);
|
button6.addActionListener(actionListener);
|
||||||
button9.addActionListener(actionListener);
|
button7.addActionListener(actionListener);
|
||||||
button0.addActionListener(actionListener);
|
button8.addActionListener(actionListener);
|
||||||
punkt.addActionListener(actionListener);
|
button9.addActionListener(actionListener);
|
||||||
plus.addActionListener(actionListener);
|
button0.addActionListener(actionListener);
|
||||||
minus.addActionListener(actionListener);
|
punkt.addActionListener(actionListener);
|
||||||
divid.addActionListener(actionListener);
|
plus.addActionListener(actionListener);
|
||||||
multi.addActionListener(actionListener);
|
minus.addActionListener(actionListener);
|
||||||
eingabe.addActionListener(actionListener);
|
divid.addActionListener(actionListener);
|
||||||
berechnen.addActionListener(actionListener);
|
multi.addActionListener(actionListener);
|
||||||
clear.addActionListener(actionListener);
|
eingabe.addActionListener(actionListener);
|
||||||
back.addActionListener(actionListener);
|
berechnen.addActionListener(actionListener);
|
||||||
}
|
clear.addActionListener(actionListener);
|
||||||
|
back.addActionListener(actionListener);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
package Übungen.TicTac;
|
package Übungen.TicTac;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class SpielfeldGUI {
|
public class SpielfeldGUI {
|
||||||
|
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
private JButton[][] buttons;
|
private JButton[][] buttons;
|
||||||
|
|
||||||
public SpielfeldGUI() {
|
public SpielfeldGUI() {
|
||||||
frame = new JFrame("Spielfeld");
|
frame = new JFrame("Spielfeld");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.setSize(300, 300);
|
frame.setSize(300, 300);
|
||||||
|
|
||||||
// Erstelle ein 3x3 GridLayout
|
// Erstelle ein 3x3 GridLayout
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setLayout(new GridLayout(3, 3));
|
panel.setLayout(new GridLayout(3, 3));
|
||||||
|
|
||||||
// Erstelle das Spielfeld mit 3x3 Buttons
|
// Erstelle das Spielfeld mit 3x3 Buttons
|
||||||
buttons = new JButton[3][3];
|
buttons = new JButton[4][4];
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
buttons[i][j] = new JButton("-");
|
buttons[i][j] = new JButton("-");
|
||||||
buttons[i][j].addActionListener(e -> {
|
buttons[i][j].addActionListener(e -> {
|
||||||
JButton clickedButton = (JButton) e.getSource();
|
JButton clickedButton = (JButton) e.getSource();
|
||||||
clickedButton.setText("X"); // Ändert den Text zu "X" beim Klick
|
clickedButton.setText("X"); // Ändert den Text zu "X" beim Klick
|
||||||
});
|
});
|
||||||
panel.add(buttons[i][j]);
|
panel.add(buttons[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Füge das Panel zum Frame hinzu
|
// Füge das Panel zum Frame hinzu
|
||||||
frame.add(panel);
|
frame.add(panel);
|
||||||
frame.setVisible(true); // Zeige das Fenster an
|
frame.setVisible(true); // Zeige das Fenster an
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Starte die GUI
|
// Starte die GUI
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
new SpielfeldGUI();
|
new SpielfeldGUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
package Übungen.TicTac;
|
package Übungen.TicTac;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import javax.swing.border.LineBorder;
|
import javax.swing.border.LineBorder;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class View extends JFrame {
|
public class View extends JFrame {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
JLabel nameSpieler1;
|
JLabel nameSpieler1;
|
||||||
JLabel nameSpieler2;
|
JLabel nameSpieler2;
|
||||||
JLabel anzahlgewinn1;
|
JLabel anzahlgewinn1;
|
||||||
JLabel anzahlgewinn2;
|
JLabel anzahlgewinn2;
|
||||||
JLabel XoderO;
|
JLabel XoderO;
|
||||||
JButton[][] x_o;
|
JButton[][] x_o;
|
||||||
|
|
||||||
public View() {
|
public View() {
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
this.setBounds(100, 100, 626, 709);
|
this.setBounds(100, 100, 626, 709);
|
||||||
this.contentPane = new JPanel();
|
this.contentPane = new JPanel();
|
||||||
this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
contentPane.setLayout(null);
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setBorder(new LineBorder(new Color(128, 255, 128), 2));
|
panel.setBorder(new LineBorder(new Color(128, 255, 128), 2));
|
||||||
panel.setBackground(new Color(192, 192, 192));
|
panel.setBackground(new Color(192, 192, 192));
|
||||||
panel.setBounds(38, 36, 529, 585);
|
panel.setBounds(38, 36, 529, 585);
|
||||||
contentPane.add(panel);
|
contentPane.add(panel);
|
||||||
panel.setLayout(null);
|
panel.setLayout(null);
|
||||||
|
|
||||||
nameSpieler1 = new JLabel();
|
nameSpieler1 = new JLabel();
|
||||||
nameSpieler1.setBounds(46, 27, 100, 14);
|
nameSpieler1.setBounds(46, 27, 100, 14);
|
||||||
panel.add(nameSpieler1);
|
panel.add(nameSpieler1);
|
||||||
|
|
||||||
anzahlgewinn1 = new JLabel();
|
anzahlgewinn1 = new JLabel();
|
||||||
anzahlgewinn1.setBounds(46, 52, 100, 14);
|
anzahlgewinn1.setBounds(46, 52, 100, 14);
|
||||||
panel.add(anzahlgewinn1);
|
panel.add(anzahlgewinn1);
|
||||||
|
|
||||||
nameSpieler2 = new JLabel();
|
nameSpieler2 = new JLabel();
|
||||||
nameSpieler2.setBounds(391, 27, 100, 14);
|
nameSpieler2.setBounds(391, 27, 100, 14);
|
||||||
panel.add(nameSpieler2);
|
panel.add(nameSpieler2);
|
||||||
|
|
||||||
anzahlgewinn2 = new JLabel();
|
anzahlgewinn2 = new JLabel();
|
||||||
anzahlgewinn2.setBounds(391, 52, 100, 14);
|
anzahlgewinn2.setBounds(391, 52, 100, 14);
|
||||||
panel.add(anzahlgewinn2);
|
panel.add(anzahlgewinn2);
|
||||||
|
|
||||||
XoderO = new JLabel("New label");
|
XoderO = new JLabel("New label");
|
||||||
XoderO.setBounds(222, 41, 100, 14);
|
XoderO.setBounds(222, 41, 100, 14);
|
||||||
panel.add(XoderO);
|
panel.add(XoderO);
|
||||||
|
|
||||||
JButton btnNewButton = new JButton("New Game");
|
JButton btnNewButton = new JButton("New Game");
|
||||||
btnNewButton.setBounds(196, 447, 129, 23);
|
btnNewButton.setBounds(196, 447, 129, 23);
|
||||||
panel.add(btnNewButton);
|
panel.add(btnNewButton);
|
||||||
|
|
||||||
JPanel panel_1 = new JPanel();
|
JPanel panel_1 = new JPanel();
|
||||||
panel_1.setBounds(101, 125, 312, 291);
|
panel_1.setBounds(101, 125, 312, 291);
|
||||||
panel.add(panel_1);
|
panel.add(panel_1);
|
||||||
panel_1.setLayout(new GridLayout(3, 3, 0, 0));
|
panel_1.setLayout(new GridLayout(3, 3, 0, 0));
|
||||||
|
|
||||||
x_o = new JButton[3][3];
|
x_o = new JButton[3][3];
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
x_o[i][j] = new JButton("-");
|
x_o[i][j] = new JButton("-");
|
||||||
panel_1.add(x_o[i][j]);
|
panel_1.add(x_o[i][j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.add(panel_1);
|
panel.add(panel_1);
|
||||||
|
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue