master
3009594 2024-12-15 23:32:50 +01:00
parent d7836fd17c
commit 7aa59568dc
25 changed files with 1060 additions and 1122 deletions

View File

@ -6,7 +6,7 @@
</attributes>
</classpathentry>
<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>
<attribute name="module" value="true"/>
</attributes>

View File

@ -1,11 +1,10 @@
package BankSystemGUI;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.BeforeEach;
class JTest {
User obai;

View File

@ -1,13 +1,10 @@
package BinaryTree;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class JuintTeste {
@Test
void test() {
BinaryBaumList b1 = new BinaryBaumList();
b1.addElement(15);

View File

@ -3,32 +3,34 @@ package BinaryTree;
public class Test {
public static void main(String[] args) {
BinaryBaumList b1 = new BinaryBaumList();
b1.addElement(50);
b1.addElement(30);
b1.addElement(70);
b1.addElement(20);
b1.addElement(40);
b1.addElement(60);
b1.addElement(80);
b1.addElement(15);
b1.addElement(22);
b1.addElement(35);
b1.addElement(45);
b1.addElement(21);
b1.addElement(25);
// BinaryBaumList b1 = new BinaryBaumList();
// b1.addElement(50);
// b1.addElement(30);
// b1.addElement(70);
// b1.addElement(20);
// b1.addElement(40);
// b1.addElement(60);
// b1.addElement(80);
// b1.addElement(15);
// b1.addElement(22);
// b1.addElement(35);
// b1.addElement(45);
// b1.addElement(21);
// 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("[");
b1.printDepth();
System.out.print("]");
System.out.println();
b1.removNode(30);
System.out.print("[");
b1.printDepth();
System.out.print("]");
System.out.println('G' > 'F');
}

View File

@ -2,14 +2,12 @@ package GUIAnwendungen;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
@ -30,7 +28,6 @@ public class Jpanel {
// و وضعنا له حدود و عنوان Layout Manager لا يستخدم أي Panel هنا قمنا بتعريف
JPanel panel = new JPanel(null);
panel.setBorder(BorderFactory.createTitledBorder("Add User"));
panel.setBounds(50, 30, 290, 300);
// Frame في الـ Panel هنا وضعنا الـ

View File

@ -9,7 +9,6 @@ import java.awt.Font;
import java.text.SimpleDateFormat;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
@ -28,7 +27,6 @@ public class Labels {
JLabel label = new JLabel();
// Erstelle einen Border für das Fenster
Border b1 = BorderFactory.createLineBorder(Color.GREEN,5);
// füge den Text auf dem Fenster hinzu
label.setText("Hall Welt");
@ -60,7 +58,6 @@ public class Labels {
label.setOpaque(true);
//zeige den Border auf dem Fenster
label.setBorder(b1);
//füge ein Bild hinzu

View File

@ -2,7 +2,6 @@ package GUIAnwendungen;
import java.awt.Color;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

View File

@ -1,13 +1,11 @@
package Hashmap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import Hashmap.MyGenericHashMap.Entry;
class JunitTest {
private MyGenericHashMap<Integer,String> h1;

View File

@ -10,7 +10,7 @@ public class TimerKlasse extends TimerTask {
Timer timer = new Timer();
TimerTask task = new TimerKlasse();
timer.schedule(task,1000);
timer.schedule(task,5000);
}
@Override

View File

@ -96,6 +96,24 @@ public class GUI_addTask extends JFrame {
submitTask = new JButton("Submit");
submitTask.setBounds(24, 323, 123, 23);
panel.add(submitTask);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(229, 333, 2, 2);
panel.add(scrollPane);
JCheckBox chckbxNewCheckBox = new JCheckBox("New check box");
chckbxNewCheckBox.setBounds(148, 383, 97, 23);
panel.add(chckbxNewCheckBox);
JButton resest = new JButton("Reset");
resest.setForeground(new Color(64, 0, 128));
resest.setFont(new Font("Microsoft Tai Le", Font.BOLD, 14));
resest.setBounds(221, 317, 144, 34);
panel.add(resest);
JCheckBox chckbxNewCheckBox_1 = new JCheckBox("New check box");
chckbxNewCheckBox_1.setBounds(268, 240, 112, 23);
panel.add(chckbxNewCheckBox_1);
setLocationRelativeTo(null);
}

View File

@ -2,7 +2,7 @@ package VorlesungsFolien.Verebung;
public class A {
void f() {
public void f() {
System.out.println("A");
}
@ -11,17 +11,13 @@ public class A {
A a2 = new B();
B b = new B();
a1.f();
// Ausgabe B:
// Das passiert aufgrund des Konzepts des Polymorphismus
// Dies liegt am Prinzip der dynamischen Bindung
a2.f();
}
}
class B extends A {
void f() {
public void f() {
System.out.println("B");
}
}

View File

@ -23,7 +23,7 @@ public class Firma {
// nein, weil nicht jeder manager ein Geschaeftsfuehrer ist, aber jeder Geschaeftsfuehrer ist ein manager
if (mi instanceof Geschaeftsfuehrer)
System.out.println("Ja");
System.out.println("Jalll");
if (null instanceof Geschaeftsfuehrer )
System.out.println("null");

View File

@ -7,8 +7,6 @@
module Programmierung2 {
requires java.desktop;
requires org.junit.jupiter.api;
requires junit;
requires java.sql;
requires java.logging;
exports Übungen.TaschenrechnerGUI to junit; // Exportiere das Paket für das JUnit-Modul
}

Binary file not shown.

View File

@ -1,5 +1,7 @@
package oop.Generics;
import java.util.*;
public class Pocket<T> {
private T value;
@ -9,6 +11,9 @@ public class Pocket<T> {
this.value = value;
}
public static <G> G getT(G g) {
return g;
}
public T getValue() {
return value;
@ -26,12 +31,7 @@ public class Pocket<T> {
public static void main(String[] args) {
Pocket<Pocket<String>> pocketOfPockets = new Pocket<>();
pocketOfPockets.setValue(new Pocket<String>());
pocketOfPockets.getValue().setValue("Innere Pocket");
System.out.println(pocketOfPockets.getValue().getValue());
//-----------------------------------------------------------------
Pocket<String>[] pocket = new Pocket[10]; // mit 10 Plätzen
List<Object> stringList = new ArrayList<>();
}

View File

@ -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 + " ");
}
}

View File

@ -6,38 +6,10 @@ public class Beispiele {
public static void main(String[] args) {
Integer[] myArray = new Integer[] { 10, 20, 22, 30, 50 };
Stream<Integer> myStream = Arrays.stream(myArray);
/*
* Hier macht der Stream nichts, weil die Intermediate-Operation filter keine
* 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 };
IntStream.of(array).forEach(System.out::print);
}

View File

@ -1,7 +1,6 @@
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 java.util.ArrayList;

View File

@ -1,6 +1,6 @@
package Übungen.MyBankSystem;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;

View File

@ -1,7 +1,4 @@
package Übungen;
import java.awt.EventQueue;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
@ -11,16 +8,10 @@ public class Stopuhr extends JFrame {
JPanel contentPane;
JLabel zeige_zeit;
JButton start_zeit, stop_zeit_1;
JTextArea zeige_alleZeiten;
Timer timer, print_alleZeiten;
boolean aktiv;
JButton start_zeit;
Timer timer;
long startzeit;
int speichere_alle_zeiten_index = 0;
ArrayList<String> speichere_alle_zeiten = new ArrayList<>();
public Stopuhr() {
this.setTitle("Stopuhr");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -31,69 +22,33 @@ public class Stopuhr extends JFrame {
contentPane.setLayout(null);
zeite_elemente();
start_programm();
this.setVisible(true);
}
public void start_programm() {
aktiv = false;
timer = new Timer(100, e -> update_zeit());
print_alleZeiten = new Timer(100, e -> print_next_time());
timer = new Timer(1000, e -> update_zeit());
start_zeit.addActionListener(e -> start_stopuhr());
stop_zeit_1.addActionListener(e -> stop_stopuhr());
}
public void start_stopuhr() {
if (!aktiv) {
timer.start();
startzeit = System.currentTimeMillis(); // Milisekunden
aktiv = true;
speichere_alle_zeiten_index = 0;
}else
print_alleZeiten.start();
}
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);
System.out.println(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));
@ -102,14 +57,5 @@ public class Stopuhr extends JFrame {
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);
}
}

View File

@ -1,9 +1,8 @@
package Übungen.TaschenrechnerGUI;
import static org.junit.Assert.*;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;

View File

@ -47,7 +47,7 @@ public class View extends JFrame {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setLayout(null);
getContentPane().setLayout(null);
ergebnisse.setBounds(40, 60, 300, 40);
error.setBounds(40, 60, 100, 30);
@ -59,6 +59,8 @@ public class View extends JFrame {
button5.setBounds(120,190,buttonWidth,buttonheight);
button6.setBounds(200,190,buttonWidth,buttonheight);
button7.setBounds(40,230,buttonWidth,buttonheight);
button8.setBackground(new Color(0, 64, 0));
button8.setForeground(new Color(0, 64, 0));
button8.setBounds(120,230,buttonWidth,buttonheight);
button9.setBounds(200,230,buttonWidth,buttonheight);
button0.setBounds(40,270,buttonWidth*2 + 20,buttonheight);
@ -91,27 +93,27 @@ public class View extends JFrame {
berechnen.setForeground(Color.WHITE);
berechnen.setBounds(360, 230, buttonWidth, buttonheight* 2 + 10);
this.add(clear);
this.add(error);
this.add(ergebnisse);
this.add(eingabe);
this.add(button1);
this.add(button2);
this.add(button3);
this.add(button4);
this.add(button5);
this.add(button6);
this.add(button7);
this.add(button8);
this.add(button9);
this.add(button0);
this.add(punkt);
this.add(plus);
this.add(minus);
this.add(multi);
this.add(divid);
this.add(berechnen);
this.add(back);
getContentPane().add(clear);
getContentPane().add(error);
getContentPane().add(ergebnisse);
getContentPane().add(eingabe);
getContentPane().add(button1);
getContentPane().add(button2);
getContentPane().add(button3);
getContentPane().add(button4);
getContentPane().add(button5);
getContentPane().add(button6);
getContentPane().add(button7);
getContentPane().add(button8);
getContentPane().add(button9);
getContentPane().add(button0);
getContentPane().add(punkt);
getContentPane().add(plus);
getContentPane().add(minus);
getContentPane().add(multi);
getContentPane().add(divid);
getContentPane().add(berechnen);
getContentPane().add(back);
}

View File

@ -17,7 +17,7 @@ public class SpielfeldGUI {
panel.setLayout(new GridLayout(3, 3));
// Erstelle das Spielfeld mit 3x3 Buttons
buttons = new JButton[3][3];
buttons = new JButton[4][4];
for (int i = 0; i < 3; i++) {