diff --git a/CheckstyleConfig2.xml b/CheckstyleConfig2.xml new file mode 100644 index 0000000..65aad13 --- /dev/null +++ b/CheckstyleConfig2.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/Main/CommandoZentrale.class b/bin/Main/CommandoZentrale.class new file mode 100644 index 0000000..4b86392 Binary files /dev/null and b/bin/Main/CommandoZentrale.class differ diff --git a/bin/gui/center/CenterFrame.class b/bin/gui/center/CenterFrame.class new file mode 100644 index 0000000..422f303 Binary files /dev/null and b/bin/gui/center/CenterFrame.class differ diff --git a/bin/gui/center/ControlFrame$HideListener.class b/bin/gui/center/ControlFrame$HideListener.class new file mode 100644 index 0000000..65b23ec Binary files /dev/null and b/bin/gui/center/ControlFrame$HideListener.class differ diff --git a/bin/gui/center/ControlFrame$Listener.class b/bin/gui/center/ControlFrame$Listener.class new file mode 100644 index 0000000..32a234a Binary files /dev/null and b/bin/gui/center/ControlFrame$Listener.class differ diff --git a/bin/gui/center/ControlFrame$ShowListener.class b/bin/gui/center/ControlFrame$ShowListener.class new file mode 100644 index 0000000..06ed9f1 Binary files /dev/null and b/bin/gui/center/ControlFrame$ShowListener.class differ diff --git a/bin/gui/center/ControlFrame.class b/bin/gui/center/ControlFrame.class new file mode 100644 index 0000000..5d4ad43 Binary files /dev/null and b/bin/gui/center/ControlFrame.class differ diff --git a/bin/gui/counter/Decrementer.class b/bin/gui/counter/Decrementer.class new file mode 100644 index 0000000..8a387f6 Binary files /dev/null and b/bin/gui/counter/Decrementer.class differ diff --git a/bin/gui/counter/Incrementer.class b/bin/gui/counter/Incrementer.class new file mode 100644 index 0000000..38658e0 Binary files /dev/null and b/bin/gui/counter/Incrementer.class differ diff --git a/bin/gui/counter/zipper.jardesc b/bin/gui/counter/zipper.jardesc new file mode 100644 index 0000000..6c6acbe --- /dev/null +++ b/bin/gui/counter/zipper.jardesc @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/bin/gui/dialog/Dialogtest.class b/bin/gui/dialog/Dialogtest.class new file mode 100644 index 0000000..49dc6e3 Binary files /dev/null and b/bin/gui/dialog/Dialogtest.class differ diff --git a/bin/gui/measuring/AlarmListener.class b/bin/gui/measuring/AlarmListener.class new file mode 100644 index 0000000..f34c39f Binary files /dev/null and b/bin/gui/measuring/AlarmListener.class differ diff --git a/bin/gui/measuring/Main.class b/bin/gui/measuring/Main.class new file mode 100644 index 0000000..d2b9c3a Binary files /dev/null and b/bin/gui/measuring/Main.class differ diff --git a/bin/gui/measuring/MeasuringCenter.class b/bin/gui/measuring/MeasuringCenter.class new file mode 100644 index 0000000..61a11b9 Binary files /dev/null and b/bin/gui/measuring/MeasuringCenter.class differ diff --git a/bin/gui/measuring/MeasuringDevice.class b/bin/gui/measuring/MeasuringDevice.class new file mode 100644 index 0000000..3d4196f Binary files /dev/null and b/bin/gui/measuring/MeasuringDevice.class differ diff --git a/bin/gui/measuring/MeasuringListener.class b/bin/gui/measuring/MeasuringListener.class new file mode 100644 index 0000000..25203bc Binary files /dev/null and b/bin/gui/measuring/MeasuringListener.class differ diff --git a/bin/gui/plusminus/MinusHandler.class b/bin/gui/plusminus/MinusHandler.class new file mode 100644 index 0000000..7e4b186 Binary files /dev/null and b/bin/gui/plusminus/MinusHandler.class differ diff --git a/bin/gui/plusminus/PlusHandler.class b/bin/gui/plusminus/PlusHandler.class new file mode 100644 index 0000000..99a6bee Binary files /dev/null and b/bin/gui/plusminus/PlusHandler.class differ diff --git a/bin/gui/plusminus/PlusMinus.class b/bin/gui/plusminus/PlusMinus.class new file mode 100644 index 0000000..b26bb63 Binary files /dev/null and b/bin/gui/plusminus/PlusMinus.class differ diff --git a/bin/gui/plusminus/icon.jpg b/bin/gui/plusminus/icon.jpg new file mode 100644 index 0000000..2745362 Binary files /dev/null and b/bin/gui/plusminus/icon.jpg differ diff --git a/bin/package1/Patient.class b/bin/package1/Patient.class new file mode 100644 index 0000000..d036007 Binary files /dev/null and b/bin/package1/Patient.class differ diff --git a/bin/uebungen1/DemoKlasse.class b/bin/uebungen1/DemoKlasse.class new file mode 100644 index 0000000..c34f3cc Binary files /dev/null and b/bin/uebungen1/DemoKlasse.class differ diff --git a/bin/uebungen1/Frau.class b/bin/uebungen1/Frau.class new file mode 100644 index 0000000..f6853de Binary files /dev/null and b/bin/uebungen1/Frau.class differ diff --git a/bin/uebungen1/Gruppe.class b/bin/uebungen1/Gruppe.class new file mode 100644 index 0000000..b71304a Binary files /dev/null and b/bin/uebungen1/Gruppe.class differ diff --git a/bin/uebungen1/Mann.class b/bin/uebungen1/Mann.class new file mode 100644 index 0000000..5fece49 Binary files /dev/null and b/bin/uebungen1/Mann.class differ diff --git a/bin/uebungen1/Mensch.class b/bin/uebungen1/Mensch.class new file mode 100644 index 0000000..bbc5026 Binary files /dev/null and b/bin/uebungen1/Mensch.class differ diff --git a/bin/uebungen1/binarstellen.class b/bin/uebungen1/binarstellen.class new file mode 100644 index 0000000..e1729d6 Binary files /dev/null and b/bin/uebungen1/binarstellen.class differ diff --git a/bin/uebungen7/GeomObjekt.class b/bin/uebungen7/GeomObjekt.class new file mode 100644 index 0000000..a215e52 Binary files /dev/null and b/bin/uebungen7/GeomObjekt.class differ diff --git a/bin/uebungen7/Kreis.class b/bin/uebungen7/Kreis.class new file mode 100644 index 0000000..5772ded Binary files /dev/null and b/bin/uebungen7/Kreis.class differ diff --git a/bin/uebungen7/Rechteck.class b/bin/uebungen7/Rechteck.class new file mode 100644 index 0000000..eec4035 Binary files /dev/null and b/bin/uebungen7/Rechteck.class differ diff --git a/bin/utilities/Datum.class b/bin/utilities/Datum.class new file mode 100644 index 0000000..40ac444 Binary files /dev/null and b/bin/utilities/Datum.class differ diff --git a/bin/utilities/FormatierteAusgabe.class b/bin/utilities/FormatierteAusgabe.class new file mode 100644 index 0000000..e2e6ead Binary files /dev/null and b/bin/utilities/FormatierteAusgabe.class differ diff --git a/bin/utilities/TastaturEingabe.class b/bin/utilities/TastaturEingabe.class new file mode 100644 index 0000000..4da108f Binary files /dev/null and b/bin/utilities/TastaturEingabe.class differ diff --git a/bin/utilities/Uhrzeit.class b/bin/utilities/Uhrzeit.class new file mode 100644 index 0000000..42fd9ae Binary files /dev/null and b/bin/utilities/Uhrzeit.class differ diff --git a/bin/Ãœbungen/Aufgaben.class b/bin/Ãœbungen/Aufgaben.class new file mode 100644 index 0000000..b8cd420 Binary files /dev/null and b/bin/Ãœbungen/Aufgaben.class differ diff --git a/checkstyle.properties b/checkstyle.properties new file mode 100644 index 0000000..e8fb4c6 --- /dev/null +++ b/checkstyle.properties @@ -0,0 +1,2 @@ +LeftCurly=nlow +RightCurly=same \ No newline at end of file diff --git a/src/Main/CommandoZentrale.java b/src/Main/CommandoZentrale.java new file mode 100644 index 0000000..ad67748 --- /dev/null +++ b/src/Main/CommandoZentrale.java @@ -0,0 +1,56 @@ +package Main; + +import java.awt.SystemColor; + +import org.newdawn.slick.AppGameContainer; +import org.newdawn.slick.BasicGame; +import org.newdawn.slick.GameContainer; +import org.newdawn.slick.Graphics; +import org.newdawn.slick.SlickException; + +public class CommandoZentrale extends BasicGame { + + public CommandoZentrale(String title) { + super(title); + // TODO Auto-generated constructor stub + } + + @Override + public void render(GameContainer container, Graphics g) + throws SlickException { + // TODO Auto-generated method stub + g.setDrawMode(org.newdawn.slick.Graphics.MODE_ALPHA_MAP); + + } + + @Override + public void init(GameContainer container) throws SlickException { + // TODO Auto-generated method stub + + } + + @Override + public void update(GameContainer container, int delta) + throws SlickException { + // TODO Auto-generated method stub + + } + + public static void main(String[] args) throws SlickException { + // TODO Auto-generated method stub + + final AppGameContainer app = new AppGameContainer(new CommandoZentrale("DesktopHumunculus")); + app.setDisplayMode(app.getScreenWidth(), app.getScreenHeight(), true);// + app.setTargetFrameRate(60);// Flüssige FPS von 60 + app.setVSync(true);// VSinc um Renderprobleme bei schneller + // Objektbewegung zu verhindern + //app.getTime(); + //app.hasFocus(); + + app.setShowFPS(true); + app.start(); + + + + } +} diff --git a/src/gui/center/CenterFrame.java b/src/gui/center/CenterFrame.java new file mode 100644 index 0000000..ea4af33 --- /dev/null +++ b/src/gui/center/CenterFrame.java @@ -0,0 +1,125 @@ +package gui.center; + +import java.awt.Frame; +import java.awt.Toolkit; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +import javax.swing.JFrame; + +public class CenterFrame extends JFrame implements WindowListener +{ + + public CenterFrame() + { + super("CenterFrame"); + this.setVisible(true); + // this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + } + + public void setIntoCenter() + { + this.setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2, Toolkit.getDefaultToolkit().getScreenSize().height / 2); + + System.out.println("Bildschirmdimensionen: " + Toolkit.getDefaultToolkit().getScreenSize().height + " x " + Toolkit.getDefaultToolkit().getScreenSize().width); + + } + + public static void setAllIntoCenter() + { + /* + * ablauf vorzähler perfekt um über datenstrukturen drüber zu laufen + * for(Frame currentFrame : Frame.getFrames()) { if(currentFrame + * instanceof CenterFrame) { + * ((CenterFrame)currentFrame).setIntoCenter(); } } + */ + + final Frame[] a = Frame.getFrames(); + for (int i = 0; i < Frame.getFrames().length; i++) + { + if (a[i] instanceof CenterFrame) + { + ((CenterFrame) a[i]).setIntoCenter(); + } + } + + } + + public static void setAllVisible(final boolean visibility) + { + // TODO Auto-generated method stub + + for (final Frame currentFrame : Frame.getFrames()) + { + if (currentFrame instanceof CenterFrame) + { + ((CenterFrame) currentFrame).setVisible(visibility); + } + } + + } + + public static void main(final String args[]) + { + final CenterFrame cf1 = new CenterFrame(); + cf1.setTitle("cf1"); + cf1.addWindowListener(cf1); + + final CenterFrame cf2 = new CenterFrame(); + cf2.setTitle("cf2"); + cf2.addWindowListener(cf2); + + new ControlFrame(); + + } + + @Override + public void windowActivated(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Activated " + this.getTitle()); + } + + @Override + public void windowClosed(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Closed " + this.getTitle()); + } + + @Override + public void windowClosing(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Closing " + this.getTitle()); + } + + @Override + public void windowDeactivated(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Deactivated " + this.getTitle()); + } + + @Override + public void windowDeiconified(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Deiconified " + this.getTitle()); + } + + @Override + public void windowIconified(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Iconified " + this.getTitle()); + } + + @Override + public void windowOpened(final WindowEvent e) + { + // TODO Auto-generated method stub + System.out.println("Opened " + this.getTitle()); + } + +} \ No newline at end of file diff --git a/src/gui/center/ControlFrame.java b/src/gui/center/ControlFrame.java new file mode 100644 index 0000000..319c37f --- /dev/null +++ b/src/gui/center/ControlFrame.java @@ -0,0 +1,75 @@ +package gui.center; + +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JFrame; + +public class ControlFrame extends JFrame +{ + + ControlFrame() + { + super("ControlFrame"); + this.setLayout(new GridLayout(3, 0)); + this.setVisible(true); + final JButton centerButton = new JButton("Zentrieren"); + centerButton.setName("control"); + this.add(centerButton); + final JButton hideButton = new JButton("Verstecken"); + hideButton.setName("hide"); + this.add(hideButton); + final JButton showButton = new JButton("Zeigen"); + showButton.setName("show"); + this.add(showButton); + + final Listener klick = new Listener(); + final HideListener hider = new HideListener(); + final ShowListener shower = new ShowListener(); + + centerButton.addActionListener(klick); + hideButton.addActionListener(hider); + showButton.addActionListener(shower); + this.pack(); + + } + + class Listener implements ActionListener + { + + @Override + public void actionPerformed(final ActionEvent e) + { + // TODO Auto-generated method stub + CenterFrame.setAllIntoCenter(); + } + + } + + class HideListener implements ActionListener + { + + @Override + public void actionPerformed(final ActionEvent e) + { + // TODO Auto-generated method stub + CenterFrame.setAllVisible(false); + } + + } + + class ShowListener implements ActionListener + { + + @Override + public void actionPerformed(final ActionEvent e) + { + // TODO Auto-generated method stub + CenterFrame.setAllVisible(true); + } + + } + +} diff --git a/src/gui/counter/Decrementer.java b/src/gui/counter/Decrementer.java new file mode 100644 index 0000000..1555b9a --- /dev/null +++ b/src/gui/counter/Decrementer.java @@ -0,0 +1,6 @@ +package gui.counter; + +public class Decrementer +{ + +} diff --git a/src/gui/counter/Incrementer.java b/src/gui/counter/Incrementer.java new file mode 100644 index 0000000..f96cff0 --- /dev/null +++ b/src/gui/counter/Incrementer.java @@ -0,0 +1,6 @@ +package gui.counter; + +public class Incrementer +{ + +} diff --git a/src/gui/counter/zipper.jardesc b/src/gui/counter/zipper.jardesc new file mode 100644 index 0000000..6c6acbe --- /dev/null +++ b/src/gui/counter/zipper.jardesc @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/gui/dialog/Dialogtest.java b/src/gui/dialog/Dialogtest.java new file mode 100644 index 0000000..d47a1c7 --- /dev/null +++ b/src/gui/dialog/Dialogtest.java @@ -0,0 +1,47 @@ +package gui.dialog; + +import java.awt.GridLayout; + +import javax.swing.JButton; +import javax.swing.JFrame; + +public class Dialogtest extends JFrame +{ + Dialogtest() + { + + final JFrame frame = new JFrame(); + frame.setLayout(new GridLayout(4, 0)); + + final JButton diaModAb = new JButton(); + diaModAb.setText("Dialog: Modal und JFrame Abhängig!"); + frame.add(diaModAb); + + final JButton diaNModAb = new JButton(); + diaNModAb.setText("Dialog: Nicht Modal und JFrame Abhängig!"); + frame.add(diaNModAb); + + final JButton diaModNab = new JButton(); + diaModNab.setText("Dialog: Modal und nicht JFrame Abhängig!"); + frame.add(diaModNab); + + final JButton diaNModNab = new JButton(); + diaNModNab.setText("Dialog: Nicht Modal und Nicht JFrame Abhängig!"); + frame.add(diaNModNab); + + // *Sollte JDialog als JFrame ersatz dienen, da ähnliche methoden + // beinhaltet? + frame.pack(); + frame.setVisible(true); + } + + /** + * @param args + */ + public static void main(final String[] args) + { + // TODO Auto-generated method stub + new Dialogtest(); + } + +} diff --git a/src/gui/measuring/AlarmListener.java b/src/gui/measuring/AlarmListener.java new file mode 100644 index 0000000..ff84d23 --- /dev/null +++ b/src/gui/measuring/AlarmListener.java @@ -0,0 +1,25 @@ +package gui.measuring; + +public class AlarmListener implements MeasuringListener +{ + private double unterGrenze; + + private double oberGrenze; + + public AlarmListener(double unterGrenze, double oberGrenze) + { + + unterGrenze = this.unterGrenze; + oberGrenze = this.oberGrenze; + } + + @Override + public void valueMeasured(final double value, final int iD) + { + // TODO Auto-generated method stub + if ((value > this.oberGrenze) || (value < this.unterGrenze)) + { + System.out.println("Warnung: Messgerät " + iD + " Messwert ist außerhalb des Intervalls!"); + } + } +} diff --git a/src/gui/measuring/Main.java b/src/gui/measuring/Main.java new file mode 100644 index 0000000..50f331b --- /dev/null +++ b/src/gui/measuring/Main.java @@ -0,0 +1,24 @@ +package gui.measuring; + +public class Main +{ + + /** + * @param args + */ + public static void main(final String[] args) + { + // TODO Auto-generated method stub + final AlarmListener alarm1 = new AlarmListener(0, 20.0); + final AlarmListener alarm2 = new AlarmListener(10.0, 30.0); + final MeasuringCenter center = new MeasuringCenter(); + + center.addMeasuringListener(alarm1); + center.addMeasuringListener(alarm2); + + final MeasuringDevice device1 = new MeasuringDevice(center, 1); + device1.measure(13.5); + + } + +} diff --git a/src/gui/measuring/MeasuringCenter.java b/src/gui/measuring/MeasuringCenter.java new file mode 100644 index 0000000..f5029a8 --- /dev/null +++ b/src/gui/measuring/MeasuringCenter.java @@ -0,0 +1,27 @@ +package gui.measuring; + +import java.util.ArrayList; + +public class MeasuringCenter +{ + + private ArrayList listenerList = new ArrayList(); + + public MeasuringCenter() + { + + } + + public void addMeasuringListener(final MeasuringListener listener) + { + this.listenerList.add(listener); + } + + public void reportMeasuredValues(final double messWert, final int deviceId) + { + for (final MeasuringListener i : this.listenerList) + { + i.valueMeasured(messWert, deviceId); + } + } +} diff --git a/src/gui/measuring/MeasuringDevice.java b/src/gui/measuring/MeasuringDevice.java new file mode 100644 index 0000000..6795fc4 --- /dev/null +++ b/src/gui/measuring/MeasuringDevice.java @@ -0,0 +1,19 @@ +package gui.measuring; + +public class MeasuringDevice +{ + private MeasuringCenter mc; + + private int deviceId; + + MeasuringDevice(final MeasuringCenter ms, final int deviceId) + { + this.mc = ms; + this.deviceId = deviceId; + } + + public void measure(final double wert) + { + this.mc.reportMeasuredValues(wert, this.deviceId); + } +} diff --git a/src/gui/measuring/MeasuringListener.java b/src/gui/measuring/MeasuringListener.java new file mode 100644 index 0000000..150b922 --- /dev/null +++ b/src/gui/measuring/MeasuringListener.java @@ -0,0 +1,8 @@ +package gui.measuring; + +public interface MeasuringListener +{ + + public void valueMeasured(double value, int newValue); + +} diff --git a/src/gui/plusminus/MinusHandler.java b/src/gui/plusminus/MinusHandler.java new file mode 100644 index 0000000..01b16e6 --- /dev/null +++ b/src/gui/plusminus/MinusHandler.java @@ -0,0 +1,28 @@ +package gui.plusminus; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + + +public class MinusHandler implements ActionListener +{ + private PlusMinus pM; + + MinusHandler(PlusMinus pM) + { + this.pM = pM; + } + + + + @Override + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + pM.decrement(); + } +} + + + diff --git a/src/gui/plusminus/PlusHandler.java b/src/gui/plusminus/PlusHandler.java new file mode 100644 index 0000000..de3e227 --- /dev/null +++ b/src/gui/plusminus/PlusHandler.java @@ -0,0 +1,25 @@ +package gui.plusminus; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + + +public class PlusHandler implements ActionListener +{ + private PlusMinus pM; + + PlusHandler(PlusMinus pM) + { + this.pM = pM; + } + + + @Override + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + pM.increment(); + } + +} diff --git a/src/gui/plusminus/PlusMinus.java b/src/gui/plusminus/PlusMinus.java new file mode 100644 index 0000000..ce377ef --- /dev/null +++ b/src/gui/plusminus/PlusMinus.java @@ -0,0 +1,101 @@ +package gui.plusminus; + +import java.awt.GridLayout; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; + +public class PlusMinus extends JFrame +{ + + private ImageIcon icon = new ImageIcon("src/gui/plusminus/icon.jpg"); + + /* + * URL plusIconURL = IconPluMinusURLs.class.getResource("icons/up.png) Icon + * plusIcon = new ImageIcon(plusIconURL); + */ + + private JLabel label = new JLabel(); + + private int min, max, positiverWert, value; + + private JButton minus = new JButton("-", this.icon); + + private JButton plus = new JButton("+", this.icon); + + public PlusMinus(final int min, final int max, final int positiverWert) + { + super("PlusMinus"); + + this.min = min; + this.max = max; + this.positiverWert = positiverWert; + this.value = min; + + this.setLayout(new GridLayout(3, 0)); + + this.plus.setName("plus"); + this.plus.setToolTipText("Erhöhen der Zahl"); + this.add(this.plus); + this.plus.addActionListener(new PlusHandler(this)); + + this.label.setName("label"); + this.label.setText("" + this.value); + this.add(this.label); + + this.minus.setName("minus"); + this.minus.setToolTipText("Verringern der Zahl"); + this.add(this.minus); + this.minus.addActionListener(new MinusHandler(this)); + + this.checkButtons(); + this.pack(); + this.setVisible(true); + + } + + public void checkButtons() + { + if ((this.value + this.positiverWert) > this.max) + { + this.plus.setEnabled(false); + } + else + { + this.plus.setEnabled(true); + } + + if ((this.value - this.positiverWert) < this.min) + { + this.minus.setEnabled(false); + } + else + { + this.minus.setEnabled(true); + } + } + + public void decrement() + { + // TODO Auto-generated method stub + this.value = this.value - this.positiverWert; + this.checkButtons(); + this.label.setText("" + this.value); + } + + public void increment() + { + this.value = this.value + this.positiverWert; + this.checkButtons(); + this.label.setText("" + this.value); + } + + public static void main(final String[] args) + { + // TODO Auto-generated method stub + new PlusMinus(-10, 10, 1); + + } +} \ No newline at end of file diff --git a/src/gui/plusminus/icon.jpg b/src/gui/plusminus/icon.jpg new file mode 100644 index 0000000..2745362 Binary files /dev/null and b/src/gui/plusminus/icon.jpg differ diff --git a/src/package1/Patient.java b/src/package1/Patient.java new file mode 100644 index 0000000..460fcd7 --- /dev/null +++ b/src/package1/Patient.java @@ -0,0 +1,71 @@ +package package1; + +public class Patient +{ + private String name; + + private int alter; + + private Patient vorgaenger = null; + + static private int folgeNummer = 1; + + private int warteNummer; + + Patient(final String name, final int alter) + { + this.name = name; + this.alter = alter; + this.warteNummer = Patient.folgeNummer; + Patient.folgeNummer++; + + } + + Patient(final String name, final int alter, final Patient vorgaenger) + { + this.name = name; + this.alter = alter; + this.warteNummer = Patient.folgeNummer; + Patient.folgeNummer++; + } + + public boolean istErster() + { + if (this.vorgaenger == null) + { + return true; + } + else + { + return false; + } + } + + public int altersDifferenz(final Patient t) + { + if (this.alter > t.alter) + { + return this.alter - t.alter; + } + else + { + return t.alter - this.alter; + // return static int Math.abs(this.alter-t.alter); + } + } + + @Override + public String toString() + { + String s = new String("name: " + this.name + " warteNr: " + this.warteNummer + "\n "); + + if (this.vorgaenger != null) + { + s += new String(" Vorgaenger: "); + s += this.vorgaenger.toString(); + } + return s; + + } + +} diff --git a/src/uebungen1/DemoKlasse.java b/src/uebungen1/DemoKlasse.java new file mode 100644 index 0000000..f627feb --- /dev/null +++ b/src/uebungen1/DemoKlasse.java @@ -0,0 +1,47 @@ +package uebungen1; + +public class DemoKlasse +{ + + private int wert; + + DemoKlasse() + { + this.wert = 0; + } + + public int getWert() + { + return this.wert; + } + + public void setWert(final int wert) + { + this.wert = wert; + } + + public DemoKlasse addieren(final DemoKlasse obj) + { + final DemoKlasse neuesObjekt = new DemoKlasse(); + + neuesObjekt.wert = this.wert + obj.wert; + return neuesObjekt; + } + + /** + * @param args + */ + public static void main(final String[] args) + { + // TODO Auto-generated method stub + DemoKlasse a1 = new DemoKlasse(); + final DemoKlasse a2 = new DemoKlasse(); + + a1.setWert(5); + a2.setWert(6); + + a1 = a1.addieren(a2); + System.out.println("" + a1.getWert()); + + } +} diff --git a/src/uebungen1/Gruppe.java b/src/uebungen1/Gruppe.java new file mode 100644 index 0000000..5ad5c93 --- /dev/null +++ b/src/uebungen1/Gruppe.java @@ -0,0 +1,32 @@ +package uebungen1; + +import java.util.ArrayList; + +class Gruppe +{ + + + public Gruppe() + { + ArrayList mensch; + } + void addGruppenmitglied (Mensch member) + { + + } +} + +interface Mensch +{ + +} + +class Mann implements Mensch +{ + +} + +class Frau implements Mensch +{ + +} \ No newline at end of file diff --git a/src/uebungen1/binarstellen.java b/src/uebungen1/binarstellen.java new file mode 100644 index 0000000..9cb9dde --- /dev/null +++ b/src/uebungen1/binarstellen.java @@ -0,0 +1,42 @@ +package uebungen1; + +import utilities.TastaturEingabe; + +public class binarstellen +{ + + /** + * @param args + */ + + public static void main(final String[] args) + { + // TODO Auto-generated method stub + int n; + + for (int i = 0; i <= 10; i++) + { + n = TastaturEingabe.readInt("Geben Sie die nächste Zahl ein: "); + + if (n == 6) + { + break; + } + + if ((n % 3) == 0) + { + continue; + } + + if (n < 8) + { + System.out.println("" + (n * n)); + } + else + { + System.out.println("" + n); + } + } + } + +} diff --git a/src/uebungen7/GeomObjekt.java b/src/uebungen7/GeomObjekt.java new file mode 100644 index 0000000..430adc6 --- /dev/null +++ b/src/uebungen7/GeomObjekt.java @@ -0,0 +1,29 @@ +package uebungen7; + +public abstract class GeomObjekt +{ + + protected int x, y; + + GeomObjekt() + { + this.x = 0; + this.y = 0; + } + + /** + * @param args + */ + + public void print() + { + + } + + public static void main(final String[] args) + { + // TODO Auto-generated method stub + + } + +} diff --git a/src/uebungen7/Kreis.java b/src/uebungen7/Kreis.java new file mode 100644 index 0000000..0867dff --- /dev/null +++ b/src/uebungen7/Kreis.java @@ -0,0 +1,23 @@ +package uebungen7; + +public class Kreis extends GeomObjekt +{ + + private int d; + + public Kreis() + { + // TODO Auto-generated constructor stub + this.d = 0; + } + + /** + * @param args + */ + @Override + public void print() + { + System.out.println("Kreis"); + } + +} diff --git a/src/uebungen7/Rechteck.java b/src/uebungen7/Rechteck.java new file mode 100644 index 0000000..6abfd0f --- /dev/null +++ b/src/uebungen7/Rechteck.java @@ -0,0 +1,18 @@ +package uebungen7; + +public class Rechteck extends GeomObjekt +{ + private int l, b; + + Rechteck() + { + this.l = 0; + this.b = 0; + } + + @Override + public void print() + { + System.out.println("Rechteck"); + } +} diff --git a/src/utilities/Datum.java b/src/utilities/Datum.java new file mode 100644 index 0000000..ee9a722 --- /dev/null +++ b/src/utilities/Datum.java @@ -0,0 +1,80 @@ +package utilities; + +import java.util.GregorianCalendar; + +public class Datum +{ + private int tag, monat, jahr; + + // aktuelles Datum (d.h., heute) erzeugen + public Datum() + { + GregorianCalendar gc = new GregorianCalendar(); + tag = gc.get(GregorianCalendar.DAY_OF_MONTH); + // In der Klasse GregorianCalendar werden die Monate von 0 bis 11 + // durchnummeriert; daher muessen wir den Wert 1 addieren. + monat = gc.get(GregorianCalendar.MONTH) + 1; + jahr = gc.get(GregorianCalendar.YEAR); + } + + public Datum(int t, int m, int j) + { + tag = t; + monat = m; + jahr = j; + } + + public String toString() + { + return tag + "." + monat + "." + jahr; + } + + public boolean equals(Object obj) + { + if (obj instanceof Datum) + { + Datum d = (Datum)obj; + + return jahr == d.jahr + && monat == d.monat + && tag == d.tag; + } + else + return false; + } + + public boolean frueherAls(Datum d) + { + if(jahr < d.jahr) + return true; + if(jahr == d.jahr) + { + if(monat < d.monat) + return true; + if(monat == d.monat) + return tag < d.tag; + } + return false; + } + + public boolean vor(Datum d) + { + return frueherAls(d); + } + + public boolean nach(Datum d) + { + return !vor(d) && !equals(d); + } + + + public static void main(String[] args) + { + Datum d = new Datum(); + System.out.println(d); + Datum e = new Datum(6, 4, 2002); + System.out.println(e); + System.out.println(d.vor(e)); + System.out.println(d.nach(e)); + } +} diff --git a/src/utilities/FormatierteAusgabe.java b/src/utilities/FormatierteAusgabe.java new file mode 100644 index 0000000..8e281e4 --- /dev/null +++ b/src/utilities/FormatierteAusgabe.java @@ -0,0 +1,154 @@ +package utilities; + +/** + * Klasse zur formatierten Ausgabe einfacher Datentypen + */ + +public class FormatierteAusgabe +{ + private static int zehn_hoch(int potenz) + { int erg=1; + for (int i=0;i=zehn_hoch(lbreite)) + { erg="|"+zahl; + return erg; + } + for (int i=lbreite-1;i>0;i--) + if (zahl=zehn_hoch(lbreite)) + { erg="|"+zahl; + return erg; + } + for (int i=lbreite-1;i>0;i--) + if (zahlbreite) + return s.substring(s.length()-breite); + for (i=0;i=0; i--) + { if ((zahl & (EINS< + * @param b true: Meldung "Weiter ..." wird ausgegeben + */ + public static void warte(boolean b) + { + String s; + if (b) + { + System.out.print("....... Weiter mit "); + System.out.flush(); + } + s = readString(""); + } + + /** + * wartet auf + * Meldung "....... Weiter mit " wird immer ausgegeben + */ + public static void warte() + { + warte(true); + } + + public static Datum readDatum (String prompt) + { + while (true) + { + System.out.print(prompt); + try + { + String zeile = eing.readLine(); + if (zeile.length()!=10) throw new NumberFormatException(); + int tag = Integer.parseInt(zeile.substring(0,2)); + char trenn = zeile.charAt(2); + if (trenn!='.' & trenn!='/') throw new NumberFormatException(); + int monat = Integer.parseInt(zeile.substring(3,5)); + trenn = zeile.charAt(5); + if (trenn!='.' & trenn!='/') throw new NumberFormatException(); + int jahr = Integer.parseInt(zeile.substring(6,10)); + Datum einDatum = new Datum (tag, monat, jahr); + return einDatum; + } + catch (NumberFormatException e) + { + System.out.println ("Bitte eine Datum in der Form tt.mm.jjjj eingeben."); + } + catch (IllegalArgumentException e) + { + System.out.println ("Fehler in Datum: " + e.getMessage()); + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(1); + } + } + } + +} diff --git a/src/utilities/Uhrzeit.java b/src/utilities/Uhrzeit.java new file mode 100644 index 0000000..107505f --- /dev/null +++ b/src/utilities/Uhrzeit.java @@ -0,0 +1,139 @@ +package utilities; + +class Uhrzeit implements Comparable +{ + private int std; // 0 bis 23 + private int min, sek; // 0 bis 59 + private int zone; // Zeitzone in Werten von -11 bis +12 + + private static int stdNormal; + private static int minNormal; + + static void setzeNormalzeit (int std, int min) + { + stdNormal = std; + minNormal = min; + } + + Uhrzeit () + { + std = stdNormal; + min = minNormal; + // weitere Angaben nicht nötig (Standardvorbelegung) + } + + Uhrzeit (int std, int min) + { + setzeStdMin (std, min); + } + + Uhrzeit (int std, int min, int sek) + { + setzeUhrzeit (std, min, sek); + } + + Uhrzeit (int std, int min, int sek, int zone) + { + setzeUhrzeit (std, min, sek, zone); + } + + private void setzeStdMin (int std, int min) + { + if (min<0) + throw new IllegalArgumentException + ("Minuten müssen >= 0 sein."); + else + while (min>=60) + min = min - 60; + this.min = min; + if (std<0) + throw new IllegalArgumentException + ("Stunden müssen >= 0 sein."); + else + while (std>=24) + std = std - 24; + this.std = std; + } + + void setzeUhrzeit (int std, int min) + { + setzeStdMin (std, min); + this.sek = 0; + } + + void setzeUhrzeit (int std, int min, int sek) + { + setzeStdMin (std, min); + if (sek<0 | sek>59) + throw new IllegalArgumentException + ("Sekunden müssen zwischen 0 und 59 liegen."); + this.sek = sek; + zone = 1; + } + + void setzeUhrzeit (int std, int min, int sek, int zone) + { + setzeStdMin (std, min); + if (sek<0 | sek>59) + throw new IllegalArgumentException + ("Sekunden müssen zwischen 0 und 59 liegen."); + this.sek = sek; + if (zone<-11 | zone>12) + throw new IllegalArgumentException + ("Zeitzone muss zwischen -11 und +12 liegen."); + this.zone = zone; + } + + String differenz(Uhrzeit bis) + { + int dStd = bis.std + bis.zone - std - zone; + int dMin = bis.min - min; + if (dMin < 0) + { + dMin = dMin + 60; + dStd--; + } + int dSek = bis.sek - sek; + if (dSek < 0) + { + dSek = dSek + 60; + dMin--; + } + return dStd + " Std " + dMin + " Min " + dSek + " Sek"; + } + + public String toString () + { + String zeit = ((std<10)?"0"+std:""+std) + ":"; + zeit = zeit + ((min<10)?"0"+min:""+min) + ":"; + zeit = zeit + ((sek<10)?"0"+sek:""+sek) + " GMT"; + zeit = zeit + ((zone<0)?"-":"+") + Math.abs(zone); + return zeit; + } + + public boolean equals(Object einObject) + { + Uhrzeit eineZeit = (Uhrzeit)einObject; + return this.std - this.zone == eineZeit.std - eineZeit.zone + & this.min == eineZeit.min; + } + + public int compareTo(Object einObject) + { + Uhrzeit z = (Uhrzeit)einObject; + return + (((this.std-this.zone)*60)+this.min)*60+this.sek + -((((z.std-z.zone)*60)+z.min)*60+z.sek); + } + + int gibStunde () + { + return std; + } + + int gibMinute() + { + return min; + } + +} diff --git a/src/Ãœbungen/Aufgaben.java b/src/Ãœbungen/Aufgaben.java new file mode 100644 index 0000000..e1b4c3c --- /dev/null +++ b/src/Ãœbungen/Aufgaben.java @@ -0,0 +1,48 @@ +package Übungen; + +import java.io.IOException; + +public class Aufgaben { + + /** + * @param args + * @throws IOException + */ + public static void main(String[] args) throws IOException { + // TODO Auto-generated method stub + int n , complexity; + + n = System.in.read(); + int count=0; + for (int i=0; i < n; i++) + for (int j=0; j < n; j++) + count++; + + //complexity = count; + System.out.println("Count: "+count); + count=0; + for (int i=n; i > 0; i--) + for (int j=i; j < n; j++) + count++; + + System.out.println("Count: "+count); + count=0; + + for (int i=1; i <= n/2; i++) + for (int j=1; j < n * n; j++) + count++; + + System.out.println("Count: "+count); + count=0; + int i = n; + do + { count++; + i= i/3; + } + while (i > 0); + + System.out.println("Count: "+count); + + } + +}