From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Master/Software Architektur/Klausur2004.txt | 40 ++++++ .../SWA-Praktikum/LightningTalk_Reichardt.pdf | Bin 0 -> 64813 bytes .../SWA-Praktikum/Patterns.pdf | Bin 0 -> 3482386 bytes .../SWA-Praktikum/Poster_SOFTVIS06_Reichardt.pdf | Bin 0 -> 84019 bytes .../SWA-Praktikum/ZFE-Poster.pdf | Bin 0 -> 100272 bytes .../Skript-Software-Architektur-2008.pdf | Bin 0 -> 9638714 bytes Master/Software Architektur/SWA_Prakt1/.classpath | 6 + Master/Software Architektur/SWA_Prakt1/.project | 17 +++ .../.settings/org.eclipse.jdt.core.prefs | 12 ++ Master/Software Architektur/SWA_Prakt1/prakt1.png | Bin 0 -> 81060 bytes .../swa_prakt1/ArithmeticAddition.java | 130 +++++++++++++++++++ .../swa_prakt1/ArithmeticDivision.java | 130 +++++++++++++++++++ .../swa_prakt1/ArithmeticExpression.java | 6 + .../swa_prakt1/ArithmeticMultiplication.java | 134 ++++++++++++++++++++ .../swa_prakt1/ArithmeticOperator.java | 20 +++ .../swa_prakt1/ArithmeticRunner.java | 32 +++++ .../swa_prakt1/ArithmeticSubstraction.java | 132 ++++++++++++++++++++ .../swa_prakt1/ArithmeticVariable.java | 22 ++++ .../swa_prakt2/ArithmeticAddition.java | 134 ++++++++++++++++++++ .../swa_prakt2/ArithmeticDivision.java | 134 ++++++++++++++++++++ .../swa_prakt2/ArithmeticExpression.java | 6 + .../swa_prakt2/ArithmeticIterator.java | 6 + .../swa_prakt2/ArithmeticMultiplication.java | 138 +++++++++++++++++++++ .../swa_prakt2/ArithmeticOperation.java | 30 +++++ .../swa_prakt2/ArithmeticRunner.java | 44 +++++++ .../swa_prakt2/ArithmeticSubstraction.java | 137 ++++++++++++++++++++ .../swa_prakt2/ArithmeticVariable.java | 28 +++++ .../net/sven_eisenhauer/swa_prakt2/EvalIter.java | 17 +++ .../net/sven_eisenhauer/swa_prakt2/ExpIter.java | 5 + .../swa_prakt2/ExpressionIterator.java | 47 +++++++ .../net/sven_eisenhauer/swa_prakt2/PrintIter.java | 19 +++ Master/Software Architektur/SWA_Prakt3/.classpath | 6 + Master/Software Architektur/SWA_Prakt3/.project | 17 +++ .../.settings/org.eclipse.jdt.core.prefs | 12 ++ .../src/swa/prakt3/ArithmeticAddition.java | 14 +++ .../src/swa/prakt3/ArithmeticDivision.java | 14 +++ .../src/swa/prakt3/ArithmeticExpression.java | 7 ++ .../src/swa/prakt3/ArithmeticMultiplication.java | 16 +++ .../src/swa/prakt3/ArithmeticOperation.java | 28 +++++ .../src/swa/prakt3/ArithmeticSubstraction.java | 14 +++ .../src/swa/prakt3/ArithmeticVariable.java | 24 ++++ .../SWA_Prakt3/src/swa/prakt3/EvalVisitor.java | 15 +++ .../SWA_Prakt3/src/swa/prakt3/ExprType.java | 5 + .../SWA_Prakt3/src/swa/prakt3/Iterator.java | 7 ++ .../SWA_Prakt3/src/swa/prakt3/Main.java | 26 ++++ .../SWA_Prakt3/src/swa/prakt3/PrintVisitor.java | 21 ++++ .../SWA_Prakt3/src/swa/prakt3/Visitor.java | 6 + 47 files changed, 1658 insertions(+) create mode 100644 Master/Software Architektur/Klausur2004.txt create mode 100644 Master/Software Architektur/SWA-Praktikum/LightningTalk_Reichardt.pdf create mode 100644 Master/Software Architektur/SWA-Praktikum/Patterns.pdf create mode 100644 Master/Software Architektur/SWA-Praktikum/Poster_SOFTVIS06_Reichardt.pdf create mode 100644 Master/Software Architektur/SWA-Praktikum/ZFE-Poster.pdf create mode 100644 Master/Software Architektur/SWA-Vorlesung/Skript-Software-Architektur-2008.pdf create mode 100644 Master/Software Architektur/SWA_Prakt1/.classpath create mode 100644 Master/Software Architektur/SWA_Prakt1/.project create mode 100644 Master/Software Architektur/SWA_Prakt1/.settings/org.eclipse.jdt.core.prefs create mode 100644 Master/Software Architektur/SWA_Prakt1/prakt1.png create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticAddition.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticDivision.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticExpression.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticMultiplication.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticOperator.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticRunner.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticSubstraction.java create mode 100644 Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticVariable.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticAddition.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticDivision.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticExpression.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticIterator.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticMultiplication.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticOperation.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticSubstraction.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticVariable.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/EvalIter.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpIter.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpressionIterator.java create mode 100644 Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/PrintIter.java create mode 100644 Master/Software Architektur/SWA_Prakt3/.classpath create mode 100644 Master/Software Architektur/SWA_Prakt3/.project create mode 100644 Master/Software Architektur/SWA_Prakt3/.settings/org.eclipse.jdt.core.prefs create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticAddition.java create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticDivision.java create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticExpression.java create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticMultiplication.java create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticOperation.java create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticSubstraction.java create mode 100755 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticVariable.java create mode 100644 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/EvalVisitor.java create mode 100644 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ExprType.java create mode 100644 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Iterator.java create mode 100644 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java create mode 100644 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/PrintVisitor.java create mode 100644 Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Visitor.java (limited to 'Master/Software Architektur') diff --git a/Master/Software Architektur/Klausur2004.txt b/Master/Software Architektur/Klausur2004.txt new file mode 100644 index 0000000..193d7e3 --- /dev/null +++ b/Master/Software Architektur/Klausur2004.txt @@ -0,0 +1,40 @@ +1. Was versteht man unter SWA? + Geben Sie eine der gängigen Definitionen (Bass et. al.) wieder, welche die Struktur in den Vordergrund stellen. + +2. Welche Aufgabe hat die SWA im Rahmen des Software Lebenszyklus zu erfüllen? + +3. Welches Merkmal eines Programms wird durch die SWA definiert? + Geben Sie dieses Merkmal durch mindestens 3 in diesem Zusammenhang gleichbedeutende Begriffe wieder. + +4. Warum reicht es nicht für die Erfüllung der Aufgaben die SWA nicht aus Strukturen festzulegen? + Begründen und erläutern Sie ihre Antwort mit dem Satz von Rice. + +5. Welches wichtige Architektur-Element muss die Strukturen ergänzen, damit die SWA ihre Aufgabe erfüllen kann? + Welche architektonischen Verfeinerungen müssen somit parallel durchgeführt werden? + +6. Welche Artefakte des Softwareentwiklungszyklus gehören nach der Church'en These zur Architektur und welche nicht? + Besitzt somit jede Implementierung eines Programms von vorherein eine Architektur? + +7. Es gibt den Bedarf zu validieren und zu verifizieren, ob die Architektur bzw. die Implementierung eines Programms + die Nutzeranforderung erfüllt. + Begründen und erläutern Sie mit formalen Argumenten, ob, und falls ja, wie diese Verifikation durchgeführt werden kann. + +8. Die Artefakte entsprechen im wesentlichen den Abstraktionsebenen des Syntaxbaums. + Welcher Nachteil ergibt sich daraus für die Validation und Verifikation eines Artefaktes. + Wie könnten diese Nachteile vermieden werden? + +9. Die Architektur eines hierarchischen Systems kann als Syntaxbaum dargestellt werden. + Geben Sie an, welche Informationen ein jeder Knoten des Baumes grundsätzlich enthält. + Wie unterstützt die Knoteninformation die Aufgabe der Software-Architektur? + +--- + +10. (Visitor Muster) + Beschreiben und erklären Sie das Visitor-Muster unter verwendung der UML-ähnlichen Notation. + Nach welchen Kriterien sind a) im Composite Muster und b) im Visitor Muster die Methoden eines Programms sortiert? + +11. (Integration der Muster Visitor, Iterator, Composite) + Skizzieren Sie den Sourcecode für ein einfaches CAD System (Prak Bsp.) auf der Basis der Composite, des Iterator und des + Visitorentwurfsmusters. + Geben Sie insbesondere für den Teil des Programms (etwa die Traversen Methode detailierten Code an, der die 3 Muster + integriert. diff --git a/Master/Software Architektur/SWA-Praktikum/LightningTalk_Reichardt.pdf b/Master/Software Architektur/SWA-Praktikum/LightningTalk_Reichardt.pdf new file mode 100644 index 0000000..3f1fd48 Binary files /dev/null and b/Master/Software Architektur/SWA-Praktikum/LightningTalk_Reichardt.pdf differ diff --git a/Master/Software Architektur/SWA-Praktikum/Patterns.pdf b/Master/Software Architektur/SWA-Praktikum/Patterns.pdf new file mode 100644 index 0000000..faf22c9 Binary files /dev/null and b/Master/Software Architektur/SWA-Praktikum/Patterns.pdf differ diff --git a/Master/Software Architektur/SWA-Praktikum/Poster_SOFTVIS06_Reichardt.pdf b/Master/Software Architektur/SWA-Praktikum/Poster_SOFTVIS06_Reichardt.pdf new file mode 100644 index 0000000..be55f25 Binary files /dev/null and b/Master/Software Architektur/SWA-Praktikum/Poster_SOFTVIS06_Reichardt.pdf differ diff --git a/Master/Software Architektur/SWA-Praktikum/ZFE-Poster.pdf b/Master/Software Architektur/SWA-Praktikum/ZFE-Poster.pdf new file mode 100644 index 0000000..332b0cd Binary files /dev/null and b/Master/Software Architektur/SWA-Praktikum/ZFE-Poster.pdf differ diff --git a/Master/Software Architektur/SWA-Vorlesung/Skript-Software-Architektur-2008.pdf b/Master/Software Architektur/SWA-Vorlesung/Skript-Software-Architektur-2008.pdf new file mode 100644 index 0000000..b8b667d Binary files /dev/null and b/Master/Software Architektur/SWA-Vorlesung/Skript-Software-Architektur-2008.pdf differ diff --git a/Master/Software Architektur/SWA_Prakt1/.classpath b/Master/Software Architektur/SWA_Prakt1/.classpath new file mode 100644 index 0000000..07ca123 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Master/Software Architektur/SWA_Prakt1/.project b/Master/Software Architektur/SWA_Prakt1/.project new file mode 100644 index 0000000..f6706dc --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/.project @@ -0,0 +1,17 @@ + + + SWA_Prakt1 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Master/Software Architektur/SWA_Prakt1/.settings/org.eclipse.jdt.core.prefs b/Master/Software Architektur/SWA_Prakt1/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f102492 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Sun Oct 18 12:51:58 CEST 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Master/Software Architektur/SWA_Prakt1/prakt1.png b/Master/Software Architektur/SWA_Prakt1/prakt1.png new file mode 100644 index 0000000..98d327d Binary files /dev/null and b/Master/Software Architektur/SWA_Prakt1/prakt1.png differ diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticAddition.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticAddition.java new file mode 100644 index 0000000..cac4983 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticAddition.java @@ -0,0 +1,130 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticAddition extends ArithmeticOperator { + + public ArithmeticAddition(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operandSign="+"; + } + @Override + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() + num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() + num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() + num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() + num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() + num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() + num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() + num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() + num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() + num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() + num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() + num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() + num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() + num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() + num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() + num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() + num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() + num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() + num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() + num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() + num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() + num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() + num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() + num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() + num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() + num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() + num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() + num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() + num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() + num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() + num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() + num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() + num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() + num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() + num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() + num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() + num2.intValue(); + } + return res; + } +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticDivision.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticDivision.java new file mode 100644 index 0000000..9545ec9 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticDivision.java @@ -0,0 +1,130 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticDivision extends ArithmeticOperator { + + public ArithmeticDivision(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operandSign="/"; + } + + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() / num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() / num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() / num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() / num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() / num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() / num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() / num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() / num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() / num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() / num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() / num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() / num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() / num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() / num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() / num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() / num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() / num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() / num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() / num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() / num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() / num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() / num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() / num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() / num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() / num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() / num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() / num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() / num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() / num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() / num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() / num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() / num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() / num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() / num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() / num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() / num2.intValue(); + } + return res; + } +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticExpression.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticExpression.java new file mode 100644 index 0000000..1bb8351 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticExpression.java @@ -0,0 +1,6 @@ +package net.sven_eisenhauer.swa_prakt1; + +public interface ArithmeticExpression { + public void print(); + public Number evaluate(); +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticMultiplication.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticMultiplication.java new file mode 100644 index 0000000..b9d147c --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticMultiplication.java @@ -0,0 +1,134 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticMultiplication extends ArithmeticOperator { + + + + public ArithmeticMultiplication(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operandSign = "*"; + } + + @Override + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() * num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() * num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() * num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() * num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() * num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() * num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() * num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() * num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() * num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() * num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() * num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() * num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() * num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() * num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() * num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() * num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() * num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() * num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() * num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() * num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() * num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() * num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() * num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() * num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() * num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() * num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() * num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() * num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() * num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() * num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() * num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() * num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() * num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() * num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() * num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() * num2.intValue(); + } + + return res; + } +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticOperator.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticOperator.java new file mode 100644 index 0000000..b460fd0 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticOperator.java @@ -0,0 +1,20 @@ +package net.sven_eisenhauer.swa_prakt1; + +public abstract class ArithmeticOperator implements ArithmeticExpression{ + protected ArithmeticExpression operand1; + protected ArithmeticExpression operand2; + protected String operandSign; + public ArithmeticOperator(ArithmeticExpression operand1 + ,ArithmeticExpression operand2){ + this.operand1 = operand1; + this.operand2 = operand2; + } + @Override + public void print() { + System.out.print("("); + operand1.print(); + System.out.print(operandSign); + operand2.print(); + System.out.print(")"); + } +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticRunner.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticRunner.java new file mode 100644 index 0000000..b3372f4 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticRunner.java @@ -0,0 +1,32 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticRunner { + + /** + * @param args + */ + public static void main(String[] args) { + ArithmeticVariable a = new ArithmeticVariable("a", 2L); + ArithmeticVariable b = new ArithmeticVariable("b", 77); + ArithmeticVariable c = new ArithmeticVariable("c", 0.1f); + ArithmeticVariable d = new ArithmeticVariable("d", 0.00003d); + + ArithmeticExpression aAddb = new ArithmeticAddition(a,b); + ArithmeticExpression aSubc = new ArithmeticSubstraction(a,c); + ArithmeticExpression bMuld = new ArithmeticMultiplication(b, d); + + ArithmeticExpression ae1 = new ArithmeticMultiplication(aAddb, aSubc); + ArithmeticExpression ae2 = new ArithmeticSubstraction(bMuld, a); + + ArithmeticExpression ae3 = new ArithmeticDivision(new ArithmeticAddition(ae1, ae2),new ArithmeticVariable("e", 100000)); + + try { + ae3.print(); + System.out.println("\nResult: "+ae3.evaluate()); + } catch (Throwable t) { + t.printStackTrace(); + } + + } + +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticSubstraction.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticSubstraction.java new file mode 100644 index 0000000..6f284c6 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticSubstraction.java @@ -0,0 +1,132 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticSubstraction extends ArithmeticOperator { + + public ArithmeticSubstraction(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operandSign = "-"; + } + + @Override + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() -num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() -num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() -num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() -num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() -num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() -num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() -num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() -num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() -num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() -num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() -num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() -num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() -num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() -num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() -num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() -num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() -num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() -num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() -num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() -num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() -num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() -num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() -num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() -num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() -num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() -num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() -num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() -num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() -num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() -num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() -num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() -num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() -num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() -num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() -num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() -num2.intValue(); + } + + return res; + } +} diff --git a/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticVariable.java b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticVariable.java new file mode 100644 index 0000000..a3b931d --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt1/src/net/sven_eisenhauer/swa_prakt1/ArithmeticVariable.java @@ -0,0 +1,22 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticVariable implements ArithmeticExpression { + + private String name; + private Number value; + + public ArithmeticVariable(String name,Number value) { + this.name = name; + this.value = value; + } + + @Override + public Number evaluate() { + return value; + } + + @Override + public void print() { + System.out.print(name); + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticAddition.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticAddition.java new file mode 100644 index 0000000..6565e43 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticAddition.java @@ -0,0 +1,134 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticAddition extends ArithmeticOperation { + + public ArithmeticAddition(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign="+"; + } +/* @Override + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() + num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() + num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() + num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() + num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() + num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() + num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() + num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() + num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() + num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() + num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() + num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() + num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() + num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() + num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() + num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() + num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() + num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() + num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() + num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() + num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() + num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() + num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() + num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() + num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() + num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() + num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() + num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() + num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() + num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() + num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() + num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() + num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() + num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() + num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() + num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() + num2.intValue(); + } + return res; + }*/ + @Override + public Number doOperation(Number opLeft, Number opRight) { + return opLeft.doubleValue()+opRight.doubleValue(); + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticDivision.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticDivision.java new file mode 100644 index 0000000..eed617f --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticDivision.java @@ -0,0 +1,134 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticDivision extends ArithmeticOperation { + + public ArithmeticDivision(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign="/"; + } + +/* public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() / num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() / num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() / num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() / num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() / num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() / num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() / num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() / num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() / num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() / num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() / num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() / num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() / num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() / num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() / num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() / num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() / num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() / num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() / num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() / num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() / num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() / num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() / num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() / num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() / num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() / num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() / num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() / num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() / num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() / num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() / num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() / num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() / num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() / num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() / num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() / num2.intValue(); + } + return res; + }*/ + @Override + public Number doOperation(Number opLeft, Number opRight) { + return opLeft.doubleValue()/opRight.doubleValue(); + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticExpression.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticExpression.java new file mode 100644 index 0000000..393f2ac --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticExpression.java @@ -0,0 +1,6 @@ +package net.sven_eisenhauer.swa_prakt1; + +public interface ArithmeticExpression { + //public void print(); + //public Number evaluate(); +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticIterator.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticIterator.java new file mode 100644 index 0000000..371ce61 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticIterator.java @@ -0,0 +1,6 @@ +package net.sven_eisenhauer.swa_prakt1; + +public interface ArithmeticIterator { + public void print(); + public Number evaluate(); +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticMultiplication.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticMultiplication.java new file mode 100644 index 0000000..268d338 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticMultiplication.java @@ -0,0 +1,138 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticMultiplication extends ArithmeticOperation { + + + + public ArithmeticMultiplication(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign = "*"; + } + /* + @Override + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() * num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() * num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() * num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() * num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() * num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() * num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() * num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() * num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() * num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() * num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() * num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() * num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() * num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() * num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() * num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() * num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() * num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() * num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() * num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() * num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() * num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() * num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() * num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() * num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() * num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() * num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() * num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() * num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() * num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() * num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() * num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() * num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() * num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() * num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() * num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() * num2.intValue(); + } + + return res; + }*/ + @Override + public Number doOperation(Number opLeft, Number opRight) { + return opLeft.doubleValue()*opRight.doubleValue(); + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticOperation.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticOperation.java new file mode 100644 index 0000000..5bcad84 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticOperation.java @@ -0,0 +1,30 @@ +package net.sven_eisenhauer.swa_prakt1; + +public abstract class ArithmeticOperation implements ArithmeticExpression{ + protected ArithmeticExpression operand1; + protected ArithmeticExpression operand2; + protected String operationSign; + public ArithmeticOperation(ArithmeticExpression operand1 + ,ArithmeticExpression operand2){ + this.operand1 = operand1; + this.operand2 = operand2; + }/* + @Override + public void print() { + System.out.print("("); + operand1.print(); + System.out.print(operationSign); + operand2.print(); + System.out.print(")"); + }*/ + public String getOperationSign() { + return operationSign; + } + public ArithmeticExpression getLeftOperand() { + return operand1; + } + public ArithmeticExpression getRightOperand() { + return operand2; + } + public abstract Number doOperation(Number opLeft, Number opRight); +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java new file mode 100644 index 0000000..4991041 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticRunner.java @@ -0,0 +1,44 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticRunner { + + /** + * @param args + */ + public static void main(String[] args) { + ArithmeticVariable a = new ArithmeticVariable("a", 2); + ArithmeticVariable b = new ArithmeticVariable("b", 77); + ArithmeticVariable c = new ArithmeticVariable("c", 0.1); + ArithmeticVariable d = new ArithmeticVariable("d", 0.00003); + + ArithmeticExpression aAddb = new ArithmeticAddition(a,b); + ArithmeticExpression aSubc = new ArithmeticSubstraction(a,c); + ArithmeticExpression bMuld = new ArithmeticMultiplication(b, d); + + ArithmeticExpression ae1 = new ArithmeticMultiplication(aAddb, aSubc); + ArithmeticExpression ae2 = new ArithmeticSubstraction(bMuld, a); + + ArithmeticExpression root = new ArithmeticAddition(ae1, ae2); + /* + try { + root.print(); + System.out.println("\nResult: "+root.evaluate()); + } catch (Throwable t) { + t.printStackTrace(); + } + */ + try {/* + ArithmeticIterator iter = new ExpressionIterator(root); + iter.print(); + System.out.println("\n"); + iter = new ExpressionIterator(root); + System.out.println("\nEvaluate: "+iter.evaluate()+"\n"); + */ + new PrintIter().traverse(root); + System.out.println("\n"+new EvalIter().traverse(root)); + } catch (Throwable t) { + t.printStackTrace(); + } + } + +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticSubstraction.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticSubstraction.java new file mode 100644 index 0000000..92a9bca --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticSubstraction.java @@ -0,0 +1,137 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticSubstraction extends ArithmeticOperation { + + public ArithmeticSubstraction(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign = "-"; + } +/* + @Override + public Number evaluate() { + Number res = null; + Number num1 = operand1.evaluate(); + Number num2 = operand2.evaluate(); + + if(num1 instanceof Integer && num2 instanceof Integer) { + res = num1.intValue() -num2.intValue(); + } + else if(num1 instanceof Integer && num2 instanceof Long) { + res = num1.intValue() -num2.longValue(); + } + else if(num1 instanceof Integer && num2 instanceof Short) { + res = num1.intValue() -num2.shortValue(); + } + else if(num1 instanceof Integer && num2 instanceof Float) { + res = num1.intValue() -num2.floatValue(); + } + else if(num1 instanceof Integer && num2 instanceof Double) { + res = num1.intValue() -num2.doubleValue(); + } + else if(num1 instanceof Integer && num2 instanceof Byte) { + res = num1.intValue() -num2.byteValue(); + } + + else if(num1 instanceof Byte && num2 instanceof Long) { + res = num1.byteValue() -num2.longValue(); + } + else if(num1 instanceof Byte && num2 instanceof Short) { + res = num1.byteValue() -num2.shortValue(); + } + else if(num1 instanceof Byte && num2 instanceof Float) { + res = num1.byteValue() -num2.floatValue(); + } + else if(num1 instanceof Byte && num2 instanceof Double) { + res = num1.byteValue() -num2.doubleValue(); + } + else if(num1 instanceof Byte && num2 instanceof Byte) { + res = num1.byteValue() -num2.byteValue(); + } + else if(num1 instanceof Byte && num2 instanceof Integer) { + res = num1.byteValue() -num2.intValue(); + } + + else if(num1 instanceof Short && num2 instanceof Long) { + res = num1.shortValue() -num2.longValue(); + } + else if(num1 instanceof Short && num2 instanceof Short) { + res = num1.shortValue() -num2.shortValue(); + } + else if(num1 instanceof Short && num2 instanceof Float) { + res = num1.shortValue() -num2.floatValue(); + } + else if(num1 instanceof Short && num2 instanceof Double) { + res = num1.shortValue() -num2.doubleValue(); + } + else if(num1 instanceof Short && num2 instanceof Byte) { + res = num1.shortValue() -num2.byteValue(); + } + else if(num1 instanceof Short && num2 instanceof Integer) { + res = num1.shortValue() -num2.intValue(); + } + + else if(num1 instanceof Long && num2 instanceof Long) { + res = num1.longValue() -num2.longValue(); + } + else if(num1 instanceof Long && num2 instanceof Short) { + res = num1.longValue() -num2.shortValue(); + } + else if(num1 instanceof Long && num2 instanceof Float) { + res = num1.longValue() -num2.floatValue(); + } + else if(num1 instanceof Long && num2 instanceof Double) { + res = num1.longValue() -num2.doubleValue(); + } + else if(num1 instanceof Long && num2 instanceof Byte) { + res = num1.longValue() -num2.byteValue(); + } + else if(num1 instanceof Long && num2 instanceof Integer) { + res = num1.longValue() -num2.intValue(); + } + + else if(num1 instanceof Float && num2 instanceof Long) { + res = num1.floatValue() -num2.longValue(); + } + else if(num1 instanceof Float && num2 instanceof Short) { + res = num1.floatValue() -num2.shortValue(); + } + else if(num1 instanceof Float && num2 instanceof Float) { + res = num1.floatValue() -num2.floatValue(); + } + else if(num1 instanceof Float && num2 instanceof Double) { + res = num1.floatValue() -num2.doubleValue(); + } + else if(num1 instanceof Float && num2 instanceof Byte) { + res = num1.floatValue() -num2.byteValue(); + } + else if(num1 instanceof Float && num2 instanceof Integer) { + res = num1.floatValue() -num2.intValue(); + } + + else if(num1 instanceof Double && num2 instanceof Long) { + res = num1.doubleValue() -num2.longValue(); + } + else if(num1 instanceof Double && num2 instanceof Short) { + res = num1.doubleValue() -num2.shortValue(); + } + else if(num1 instanceof Double && num2 instanceof Float) { + res = num1.doubleValue() -num2.floatValue(); + } + else if(num1 instanceof Double && num2 instanceof Double) { + res = num1.doubleValue() -num2.doubleValue(); + } + else if(num1 instanceof Double && num2 instanceof Byte) { + res = num1.doubleValue() -num2.byteValue(); + } else if(num1 instanceof Double && num2 instanceof Integer) { + res = num1.doubleValue() -num2.intValue(); + } + + return res; + }*/ + + @Override + public Number doOperation(Number opLeft, Number opRight) { + return opLeft.doubleValue()-opRight.doubleValue(); + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticVariable.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticVariable.java new file mode 100644 index 0000000..a9130fb --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ArithmeticVariable.java @@ -0,0 +1,28 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ArithmeticVariable implements ArithmeticExpression { + + private String name; + private Number value; + + public ArithmeticVariable(String name,Number value) { + this.name = name; + this.value = value; + } +/* + @Override + public Number evaluate() { + return value; + } + + @Override + public void print() { + System.out.print(name); + }*/ + public String getName() { + return name; + } + public Number getValue() { + return value; + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/EvalIter.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/EvalIter.java new file mode 100644 index 0000000..f356491 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/EvalIter.java @@ -0,0 +1,17 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class EvalIter implements ExpIter { + + @Override + public Number traverse(ArithmeticExpression exp) { + if(exp instanceof ArithmeticVariable) { + return ((ArithmeticVariable) exp).getValue(); + } else { + ArithmeticOperation actOp = (ArithmeticOperation) exp; + Number leftVal = traverse(actOp.getLeftOperand()); + Number rightVal = traverse(actOp.getRightOperand()); + return actOp.doOperation(leftVal, rightVal); + } + } + +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpIter.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpIter.java new file mode 100644 index 0000000..cd5a728 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpIter.java @@ -0,0 +1,5 @@ +package net.sven_eisenhauer.swa_prakt1; + +public interface ExpIter { + public Number traverse(ArithmeticExpression exp); +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpressionIterator.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpressionIterator.java new file mode 100644 index 0000000..0cdd7a8 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/ExpressionIterator.java @@ -0,0 +1,47 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class ExpressionIterator implements ArithmeticIterator { + private ArithmeticExpression baseNode; + + public ExpressionIterator(ArithmeticExpression baseNode) { + this.baseNode = baseNode; + } + + public void print() { + if(baseNode instanceof ArithmeticVariable) { + System.out.print(((ArithmeticVariable) baseNode).getName()); + } else { + ArithmeticOperation actOperation = (ArithmeticOperation) baseNode; + ArithmeticIterator leftIter = new ExpressionIterator(actOperation.getLeftOperand()); + ArithmeticIterator rightIter = new ExpressionIterator(actOperation.getRightOperand()); + System.out.print("("); + leftIter.print(); + System.out.print(actOperation.getOperationSign()); + rightIter.print(); + System.out.print(")"); + } + } + + public Number evaluate() { + if(baseNode instanceof ArithmeticVariable) { + return ((ArithmeticVariable) baseNode).getValue(); + } else { + ArithmeticOperation actOperation = (ArithmeticOperation) baseNode; + ArithmeticIterator leftIter = new ExpressionIterator(actOperation.getLeftOperand()); + ArithmeticIterator rightIter = new ExpressionIterator(actOperation.getRightOperand()); + Number leftVal = leftIter.evaluate(); + Number rightVal = rightIter.evaluate(); + if(actOperation instanceof ArithmeticAddition) { + return leftVal.doubleValue() + rightVal.doubleValue(); + } else if(actOperation instanceof ArithmeticSubstraction) { + return leftVal.doubleValue() - rightVal.doubleValue(); + } else if(actOperation instanceof ArithmeticDivision) { + return leftVal.doubleValue() / rightVal.doubleValue(); + } else if(actOperation instanceof ArithmeticMultiplication) { + return leftVal.doubleValue() * rightVal.doubleValue(); + } else { + return null; + } + } + } +} diff --git a/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/PrintIter.java b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/PrintIter.java new file mode 100644 index 0000000..90d43d9 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt2/src/net/sven_eisenhauer/swa_prakt2/PrintIter.java @@ -0,0 +1,19 @@ +package net.sven_eisenhauer.swa_prakt1; + +public class PrintIter implements ExpIter { + + @Override + public Number traverse(ArithmeticExpression exp) { + if(exp instanceof ArithmeticVariable) { + System.out.print(((ArithmeticVariable) exp).getName()); + } else { + ArithmeticOperation actOp = (ArithmeticOperation) exp; + System.out.print("("); + traverse(actOp.getLeftOperand()); + System.out.print(actOp.getOperationSign()); + traverse(actOp.getRightOperand()); + System.out.print(")"); + } + return 0; + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/.classpath b/Master/Software Architektur/SWA_Prakt3/.classpath new file mode 100644 index 0000000..18d70f0 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Master/Software Architektur/SWA_Prakt3/.project b/Master/Software Architektur/SWA_Prakt3/.project new file mode 100644 index 0000000..c9729fd --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/.project @@ -0,0 +1,17 @@ + + + SWA_Prakt3 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Master/Software Architektur/SWA_Prakt3/.settings/org.eclipse.jdt.core.prefs b/Master/Software Architektur/SWA_Prakt3/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b1af4ee --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Mon Dec 14 14:20:47 CET 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticAddition.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticAddition.java new file mode 100755 index 0000000..efbf899 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticAddition.java @@ -0,0 +1,14 @@ +package swa.prakt3; + +public class ArithmeticAddition extends ArithmeticOperation { + + public ArithmeticAddition(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign="+"; + } + @Override + public Number doOperation(Number op1, Number op2) { + return op1.doubleValue() + op2.doubleValue() ; + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticDivision.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticDivision.java new file mode 100755 index 0000000..d8431a8 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticDivision.java @@ -0,0 +1,14 @@ +package swa.prakt3; + +public class ArithmeticDivision extends ArithmeticOperation { + + public ArithmeticDivision(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign="/"; + } + @Override + public Number doOperation(Number op1, Number op2) { + return op1.doubleValue() / op2.doubleValue() ; + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticExpression.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticExpression.java new file mode 100755 index 0000000..10ac058 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticExpression.java @@ -0,0 +1,7 @@ +package swa.prakt3; + +public abstract class ArithmeticExpression { + public ExprType type; + protected Visitor v; + public abstract Number accept(Visitor v, Iterator it); +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticMultiplication.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticMultiplication.java new file mode 100755 index 0000000..abc833a --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticMultiplication.java @@ -0,0 +1,16 @@ +package swa.prakt3; + +public class ArithmeticMultiplication extends ArithmeticOperation { + + + + public ArithmeticMultiplication(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign = "*"; + } + @Override + public Number doOperation(Number op1, Number op2) { + return op1.doubleValue() * op2.doubleValue() ; + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticOperation.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticOperation.java new file mode 100755 index 0000000..fca2f9a --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticOperation.java @@ -0,0 +1,28 @@ +package swa.prakt3; + +public abstract class ArithmeticOperation extends ArithmeticExpression{ + protected ArithmeticExpression operand1; + protected ArithmeticExpression operand2; + protected String operationSign; + public ArithmeticOperation(ArithmeticExpression operand1 + ,ArithmeticExpression operand2){ + this.operand1 = operand1; + this.operand2 = operand2; + this.type = ExprType.OPER; + } + public String getOperationSign() { + return operationSign; + } + public ArithmeticExpression getLeftOperand() { + return operand1; + } + public ArithmeticExpression getRightOperand() { + return operand2; + } + @Override + public Number accept(Visitor v, Iterator it) { + this.v = v; + return v.visit(this, it); + } + public abstract Number doOperation(Number op1, Number op2); +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticSubstraction.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticSubstraction.java new file mode 100755 index 0000000..ebb94a7 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticSubstraction.java @@ -0,0 +1,14 @@ +package swa.prakt3; + +public class ArithmeticSubstraction extends ArithmeticOperation { + + public ArithmeticSubstraction(ArithmeticExpression operand1, + ArithmeticExpression operand2) { + super(operand1, operand2); + operationSign = "-"; + } + @Override + public Number doOperation(Number op1, Number op2) { + return op1.doubleValue() - op2.doubleValue() ; + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticVariable.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticVariable.java new file mode 100755 index 0000000..943e7de --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ArithmeticVariable.java @@ -0,0 +1,24 @@ +package swa.prakt3; + +public class ArithmeticVariable extends ArithmeticExpression { + private String name; + private Number value; + + public ArithmeticVariable(String name,Number value) { + this.name = name; + this.value = value; + this.type = ExprType.VAR; + } + + public String getName() { + return name; + } + public Number getValue() { + return value; + } + @Override + public Number accept(Visitor v, Iterator it) { + this.v=v; + return v.visit(this); + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/EvalVisitor.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/EvalVisitor.java new file mode 100644 index 0000000..21b2f67 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/EvalVisitor.java @@ -0,0 +1,15 @@ +package swa.prakt3; + +public class EvalVisitor implements Visitor { + @Override + public Number visit(ArithmeticOperation ao, Iterator it) { + Number leftRes = it.traverse(ao.getLeftOperand(), this); + Number rightRes = it.traverse(ao.getRightOperand(), this); + return ao.doOperation(leftRes, rightRes); + } + + @Override + public Number visit(ArithmeticVariable av) { + return av.getValue(); + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ExprType.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ExprType.java new file mode 100644 index 0000000..1a5f106 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/ExprType.java @@ -0,0 +1,5 @@ +package swa.prakt3; + +public enum ExprType { + VAR,OPER +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Iterator.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Iterator.java new file mode 100644 index 0000000..4b333ad --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Iterator.java @@ -0,0 +1,7 @@ +package swa.prakt3; + +public class Iterator { + public Number traverse(ArithmeticExpression ae,Visitor vis) { + return ae.accept(vis,this); + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java new file mode 100644 index 0000000..919baaa --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Main.java @@ -0,0 +1,26 @@ +package swa.prakt3; + +public class Main { + + public static void main(String[] args) { + ArithmeticVariable a = new ArithmeticVariable("a", 2); + ArithmeticVariable b = new ArithmeticVariable("b", 77); + ArithmeticVariable c = new ArithmeticVariable("c", 0.1); + ArithmeticVariable d = new ArithmeticVariable("d", 0.00003); + + ArithmeticExpression aAddb = new ArithmeticAddition(a,b); + ArithmeticExpression aSubc = new ArithmeticSubstraction(a,c); + ArithmeticExpression bMuld = new ArithmeticMultiplication(b, d); + + ArithmeticExpression ae1 = new ArithmeticMultiplication(aAddb, aSubc); + ArithmeticExpression ae2 = new ArithmeticSubstraction(bMuld, a); + + ArithmeticExpression root = new ArithmeticAddition(ae1, ae2); + + Iterator iter = new Iterator(); + iter.traverse(root, new PrintVisitor()); + System.out.println(); + System.out.println(iter.traverse(root, new EvalVisitor())); + } + +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/PrintVisitor.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/PrintVisitor.java new file mode 100644 index 0000000..fd45b88 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/PrintVisitor.java @@ -0,0 +1,21 @@ +package swa.prakt3; + + + +public class PrintVisitor implements Visitor { + @Override + public Number visit(ArithmeticOperation ao, Iterator it) { + System.out.print("("); + it.traverse(ao.getLeftOperand(), this); + System.out.print(ao.getOperationSign()); + it.traverse(ao.getRightOperand(), this); + System.out.print(")"); + return null; + } + + @Override + public Number visit(ArithmeticVariable av) { + System.out.print(av.getName()); + return null; + } +} diff --git a/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Visitor.java b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Visitor.java new file mode 100644 index 0000000..995e554 --- /dev/null +++ b/Master/Software Architektur/SWA_Prakt3/src/swa/prakt3/Visitor.java @@ -0,0 +1,6 @@ +package swa.prakt3; + +public interface Visitor { + public Number visit(ArithmeticOperation ao, Iterator it); + public Number visit(ArithmeticVariable av); +} -- cgit v1.2.3