diff --git a/.idea/Robot_Factory_PR.iml b/.idea/Robot_Factory_PR.iml index dce5887..7345876 100644 --- a/.idea/Robot_Factory_PR.iml +++ b/.idea/Robot_Factory_PR.iml @@ -23,5 +23,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Main.java b/Main.java index bc56eb5..236b385 100644 --- a/Main.java +++ b/Main.java @@ -1,11 +1,29 @@ import domain.C3PO; +import domain.R2D2; +import robot.exceptions.RobotException; public class Main { public static void main(String[] args) { C3PO Herbert = new C3PO(0, "Herbert"); + R2D2 Gudrun = new R2D2(0, "Gdurun"); int[] input = {6,5,4,3,2,1}; + int[] input2 = input; + //Herbert.triggerPowerSwitch(); + //Gudrun.triggerPowerSwitch(); + try{ + Herbert.speak(input); + }catch(RobotException re){ + System.out.println(re); + } + + try{ + Gudrun.think(input2); + }catch(RobotException re){ + System.out.println(re); + } + //System.out.println("Was neues ausgeben"); //just some testing /*C3PO Herbert = new C3PO(0, "Herbert"); diff --git a/README.md b/README.md index fee4ff6..d7998ba 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,11 @@ ___ ___ ### Methods: -`--not set yet--` +`existsSavedData():boolean` + +`saveFactoryData():void -> throws` + +`loadFactoryData():Object -> throws` ## robot diff --git a/domain/C3PO.java b/domain/C3PO.java index 3bb12b0..2339858 100644 --- a/domain/C3PO.java +++ b/domain/C3PO.java @@ -1,10 +1,20 @@ package domain; +import robot.exceptions.RobotException; +import robot.interfaces.Sorting; public class C3PO extends RobotBasics { public C3PO(int id, String name){ super(id, name); } + @Override + public int[] think(int[] zahlen) throws RobotException { + return insertionSort.sorting(zahlen); + } + Sorting insertionSort = (int[] input) ->{ + System.out.println("ich sortiere mit insertion-Sort"); + return input; + }; } diff --git a/domain/R2D2.java b/domain/R2D2.java index c810ee3..4554b9b 100644 --- a/domain/R2D2.java +++ b/domain/R2D2.java @@ -1,5 +1,9 @@ package domain; +import robot.exceptions.RobotException; +import robot.exceptions.RobotIllegalStateException; +import robot.interfaces.Sorting; + public class R2D2 extends RobotBasics { /** * Constructor @@ -11,4 +15,22 @@ public class R2D2 extends RobotBasics { } + @Override + public int[] think(int[] zahlen) throws RobotException { + if(isPowerOn() == true){ + return selectionsSort.sorting(zahlen); + + }else{ + throw new RobotIllegalStateException(getName() + " is turned off."); + } + } + + + //Selectionsort... + Sorting selectionsSort = (int[] input) -> { + System.out.println("ich sortiere mit selection-Sort"); + + return input; + }; + } diff --git a/domain/R2D2Test.java b/domain/R2D2Test.java index d7e3136..93b874d 100644 --- a/domain/R2D2Test.java +++ b/domain/R2D2Test.java @@ -1,4 +1,45 @@ -import static org.junit.jupiter.api.Assertions.*; +package domain; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + class R2D2Test { - + + R2D2 Herbert; + int id = 0; + String name = "Herbert"; + @BeforeEach + void setup(){ + Herbert = new R2D2(id, name); + } + + + //Tests for basic functions + @Test + void getId() { + assertEquals(id, Herbert.getId()); + } + + @Test + void getName() { + assertEquals(name, Herbert.getName()); + } + + @Test + void triggerPowerSwitch() { + Herbert.triggerPowerSwitch(); + assertTrue(Herbert.isPowerOn()); + } + + @Test + void isPowerOn() { + assertFalse(Herbert.isPowerOn()); + Herbert.triggerPowerSwitch(); + assertTrue(Herbert.isPowerOn()); + } + } \ No newline at end of file diff --git a/domain/RobotBasics.java b/domain/RobotBasics.java index 20d5cf0..1fa9248 100644 --- a/domain/RobotBasics.java +++ b/domain/RobotBasics.java @@ -3,8 +3,8 @@ package domain; import robot.exceptions.RobotException; import robot.exceptions.RobotIllegalStateException; import robot.interfaces.Robot; -import robot.interfaces.RobotControl; -import robot.interfaces.RobotInstructions; + +import java.util.Arrays; public class RobotBasics implements Robot { @@ -18,7 +18,7 @@ public class RobotBasics implements Robot { this.power = false; } /** - * @see RobotControl + * @see robot.interfaces.RobotControl; */ @Override public int getId() { @@ -26,7 +26,7 @@ public class RobotBasics implements Robot { } /** - * @see RobotControl + * @see robot.interfaces.RobotControl; */ @Override public String getName() { @@ -34,7 +34,7 @@ public class RobotBasics implements Robot { } /** - * @see RobotControl + * @see robot.interfaces.RobotControl; */ @Override public void triggerPowerSwitch() { @@ -46,7 +46,7 @@ public class RobotBasics implements Robot { } /** - * @see RobotControl + * @see robot.interfaces.RobotControl; */ @Override public boolean isPowerOn() { @@ -54,30 +54,39 @@ public class RobotBasics implements Robot { } /** - * @see RobotInstructions + * @see robot.interfaces.RobotControl; + */ + @Override + public RobotException getLastException() { + return null; + } + + /** + * @see robot.interfaces.RobotInstructions; + * Maybe method is depractable */ @Override public String speak(int[] zahlen) throws RobotException { - if(power == true){ - String array = ""; - for(int i = 0; i < zahlen.length; i++){ - array += zahlen[i] + " "; - } - return array; + if(isPowerOn() == true){ + final String[] array = {""}; + Arrays.stream(zahlen).forEach(i -> array[0] += i + ", "); + return array[0]; }else{ - throw new RobotIllegalStateException("The Robot is turned off."); + throw new RobotIllegalStateException( name + " is turned off."); } - } /** - * @see RobotInstructions + * @see robot.interfaces.RobotInstructions + * Maybe method is depractable */ @Override public int[] think(int[] zahlen) throws RobotException { - return new int[0]; + if(isPowerOn() == true){ + return zahlen; + }else{ + throw new RobotIllegalStateException(name + " is turned off"); + } + } - - - } diff --git a/out/production/Robot_Factory_PR/.idea/Robot_Factory_PR.iml b/out/production/Robot_Factory_PR/.idea/Robot_Factory_PR.iml index dce5887..7345876 100644 --- a/out/production/Robot_Factory_PR/.idea/Robot_Factory_PR.iml +++ b/out/production/Robot_Factory_PR/.idea/Robot_Factory_PR.iml @@ -23,5 +23,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/out/production/Robot_Factory_PR/Main.class b/out/production/Robot_Factory_PR/Main.class index 02d59ac..ced57d2 100644 Binary files a/out/production/Robot_Factory_PR/Main.class and b/out/production/Robot_Factory_PR/Main.class differ diff --git a/out/production/Robot_Factory_PR/README.md b/out/production/Robot_Factory_PR/README.md index dc152df..d7998ba 100644 --- a/out/production/Robot_Factory_PR/README.md +++ b/out/production/Robot_Factory_PR/README.md @@ -17,176 +17,252 @@ # Overview ## Packages -* [Domain](#domain) - * [R2D2](#-klasse-r2d2-) - * [R2D2Test](#-testklasse-r2d2test-) - * [C3P0](#-klasse-c3po-) - * [Robot](#-interface-robot-) - * [RobotControl](#-interface-robotcontrol-) - * [RobotControl](#-interface-robotinstructions-) -* [Facade](#facade) - * [Factrory](#-klasse-factory-) -* [Infrastructure](#infratructure) - * [Persistenz](#-klasse-persistenz-) -* [UI](#ui) +* ### [Domain](#domain-1) + * [R2D2](#-classe-r2d2-) + * [R2D2Test](#-testclasse-r2d2test-) + * [C3P0](#-classe-c3po-) + * [C3POTest](#-testclasse-c3potest-) + * [RobotBasics](#-class-robotbasics-) +* ### [Facade](#facade-1) + * [Factrory](#-classe-factory-) +* ### [Infrastructure](#infratructure-1) + * [Persistenz](#-classe-persistenz-) +* ### [robot](#robot-1) + * ### [exceptions](#exceptions-1) + * [RobotException](#-class-robotexception-) + * [RobotIllegalStateException](#-class-robotillegalstateexception-) + * [RobotMagicValueException](#-class-robotmagicvalueexception-) + * ### [interfaces](#interfaces-1) + * [Robot](#-interface-robot-) + * [RobotControl](#-interface-robotcontroll-) + * [RobotInstructions](#-interface-robotinstructions-) + * [Sorting] vorläufig +* ### [UI](#ui-1) + * [UI](#-class-ui-) ## Sidefiles -* [Main](#-klasse-main-) +* [Main](#-classe-main-) * [makefile](#-makefile-for-Git-updates-) ## Domain -

Klasse R2D2

+

Class R2D2

### Variables: -``` -private int id -private String name -private boolean power -``` +`--not set yet--` ___ ### Methods: -``` -public R2D2():R2D2 -//implemented from interface Robotcontrol -public getId():int -public getName():String -public triggerPowerSWitch():void -public isPowerOn():boolean -``` +`public R2D2():R2D2` -

TestKlasse R2D2Test

+

+TestClass R2D2Test +

### Variables: -``` -public int id -public String name -public R2D2 Herbert -``` -___ + +`public int id` + +`public String name` + +`public R2D2 Herbert` +___ ### Methods: -``` -@BeforeEach -setup():void -@Test -getId():void -getName():void -triggerPowerSwitch():void -iPowerOn():void +`@BeforeEach` +`setup():void` -``` +`@Test` -

Klasse C3PO

+`getId():void` + +`getName():void` + +`triggerPowerSwitch():void` + +`iPowerOn():void` + + + +

+Class C3PO +

### Variables: -``` ---not set yet-- -``` +`--not set yet--` ___ ### Methods: -``` ---not set yet-- -``` +`//construtor` -

Interface Robot

+`public C3PO(): C3PO` + +

+TestClass C3PO +

+ +### Variables: +`public int id` + +`public String name` + +`public C3PO Herbert` +___ ### Methods: -``` ---not set yet-- -``` +`@BeforeEach` +`setup():void` + +`@Test` + +`getId():void` + +`getName():void` + +`triggerPowerSwitch():void` + +`iPowerOn():void` -

Interface RobotControl

+ +

+Class RobotBasics +

+ + +### Variables: +`private int id` + +`private String name` + +`private boolean power` + +___ ### Methods: -``` ---not set yet-- -``` +`public RobotBasics():RobotBasics` + +`public getId():int` -

Interface RobotInstructions

+`public getName():String` -### Methods: -``` ---not set yet-- -``` +`public triggerPowerSwitch():void` +`public ìsPowerOn():boolean` + +`public speak():String` + +`public think():int[]` ## facade -

Klasse Factory

+

Class Factory

### Variables: -``` ---not set yet-- -``` +`--not set yet--` ___ ### Methods: -``` ---not set yet-- -``` +`--not set yet--` ## Infrastructure -

Klasse Persistenz

+

Class Persistenz

### Variables: -``` ---not set yet-- -``` +`--not set yet--` ___ ### Methods: -``` ---not set yet-- -``` +`existsSavedData():boolean` + +`saveFactoryData():void -> throws` + +`loadFactoryData():Object -> throws` + +## robot + +### exceptions + +

+Class RobotException +

+ +#### Methods: +`public RobotException():Exception` + +

Class RobotIllegalStateException

+ +#### Methods: +`public RobotIllegalStateException():RobotException` + +

Class RobotMagicValueException

+ +#### Methods: +`public RobotMagicValueException():RobotException` + +### interfaces + +

+Interface Robot

+ +#### Methods: +`--not set yet--` + + + +

+Interface RobotControl +

+ +### Methods: +`--not set yet--` + +

+Interface RobotInstructions

+ +### Methods: +`--not set yet--` + ## UI -

Klasse UI

+

Class UI

### Variables: -``` ---not set yet-- -``` +`--not set yet--` ___ ### Methods: -``` ---not set yet-- -``` +`--not set yet--` -

Klasse Main

+ + + +

Class Main

### Variables: -``` ---not set yet-- -``` +`--not set yet--` ___ ### Methods: -``` ---not set yet-- -``` +`--not set yet--`

makefile for Git updates

### Variables: -``` ---not set yet-- -``` +`--not set yet--` ___ ### Methods: -``` -update_readme: -update_make: -update_all: -``` + +`update_readme:` + +`update_make:` + +`update_all:` + ## Aufgabe diff --git a/out/production/Robot_Factory_PR/domain/C3PO.class b/out/production/Robot_Factory_PR/domain/C3PO.class index 24cc591..99b29ad 100644 Binary files a/out/production/Robot_Factory_PR/domain/C3PO.class and b/out/production/Robot_Factory_PR/domain/C3PO.class differ diff --git a/out/production/Robot_Factory_PR/domain/R2D2.class b/out/production/Robot_Factory_PR/domain/R2D2.class index d4c6df5..f2ce9b6 100644 Binary files a/out/production/Robot_Factory_PR/domain/R2D2.class and b/out/production/Robot_Factory_PR/domain/R2D2.class differ diff --git a/out/production/Robot_Factory_PR/domain/R2D2Test.class b/out/production/Robot_Factory_PR/domain/R2D2Test.class index e4d0a82..f678611 100644 Binary files a/out/production/Robot_Factory_PR/domain/R2D2Test.class and b/out/production/Robot_Factory_PR/domain/R2D2Test.class differ diff --git a/out/production/Robot_Factory_PR/domain/RobotBasics.class b/out/production/Robot_Factory_PR/domain/RobotBasics.class index d04f6ed..d4faba1 100644 Binary files a/out/production/Robot_Factory_PR/domain/RobotBasics.class and b/out/production/Robot_Factory_PR/domain/RobotBasics.class differ diff --git a/out/production/Robot_Factory_PR/infrastructure/Persistenz.class b/out/production/Robot_Factory_PR/infrastructure/Persistenz.class index f090dbc..b173611 100644 Binary files a/out/production/Robot_Factory_PR/infrastructure/Persistenz.class and b/out/production/Robot_Factory_PR/infrastructure/Persistenz.class differ diff --git a/out/production/Robot_Factory_PR/robot/exceptions/RobotException.class b/out/production/Robot_Factory_PR/robot/exceptions/RobotException.class new file mode 100644 index 0000000..a8a54aa Binary files /dev/null and b/out/production/Robot_Factory_PR/robot/exceptions/RobotException.class differ diff --git a/out/production/Robot_Factory_PR/robot/exceptions/RobotIllegalStateException.class b/out/production/Robot_Factory_PR/robot/exceptions/RobotIllegalStateException.class new file mode 100644 index 0000000..c615c5b Binary files /dev/null and b/out/production/Robot_Factory_PR/robot/exceptions/RobotIllegalStateException.class differ diff --git a/out/production/Robot_Factory_PR/robot/exceptions/RobotMagicValueException.class b/out/production/Robot_Factory_PR/robot/exceptions/RobotMagicValueException.class new file mode 100644 index 0000000..e142b68 Binary files /dev/null and b/out/production/Robot_Factory_PR/robot/exceptions/RobotMagicValueException.class differ diff --git a/out/production/Robot_Factory_PR/robot/interfaces/Robot.class b/out/production/Robot_Factory_PR/robot/interfaces/Robot.class new file mode 100644 index 0000000..3b56f20 Binary files /dev/null and b/out/production/Robot_Factory_PR/robot/interfaces/Robot.class differ diff --git a/out/production/Robot_Factory_PR/robot/interfaces/RobotControl.class b/out/production/Robot_Factory_PR/robot/interfaces/RobotControl.class new file mode 100644 index 0000000..f47ab02 Binary files /dev/null and b/out/production/Robot_Factory_PR/robot/interfaces/RobotControl.class differ diff --git a/out/production/Robot_Factory_PR/robot/interfaces/RobotInstructions.class b/out/production/Robot_Factory_PR/robot/interfaces/RobotInstructions.class new file mode 100644 index 0000000..ab7d6de Binary files /dev/null and b/out/production/Robot_Factory_PR/robot/interfaces/RobotInstructions.class differ diff --git a/out/production/Robot_Factory_PR/roboter/interfaces/Sorting.class b/out/production/Robot_Factory_PR/robot/interfaces/Sorting.class similarity index 54% rename from out/production/Robot_Factory_PR/roboter/interfaces/Sorting.class rename to out/production/Robot_Factory_PR/robot/interfaces/Sorting.class index d73ca12..06950b3 100644 Binary files a/out/production/Robot_Factory_PR/roboter/interfaces/Sorting.class and b/out/production/Robot_Factory_PR/robot/interfaces/Sorting.class differ diff --git a/out/production/Robot_Factory_PR/roboter/exceptions/RobotException.class b/out/production/Robot_Factory_PR/roboter/exceptions/RobotException.class deleted file mode 100644 index 9dbb2e2..0000000 Binary files a/out/production/Robot_Factory_PR/roboter/exceptions/RobotException.class and /dev/null differ diff --git a/out/production/Robot_Factory_PR/roboter/exceptions/RobotIllegalStateException.class b/out/production/Robot_Factory_PR/roboter/exceptions/RobotIllegalStateException.class deleted file mode 100644 index 6939325..0000000 Binary files a/out/production/Robot_Factory_PR/roboter/exceptions/RobotIllegalStateException.class and /dev/null differ diff --git a/out/production/Robot_Factory_PR/roboter/exceptions/RobotMagicValueException.class b/out/production/Robot_Factory_PR/roboter/exceptions/RobotMagicValueException.class deleted file mode 100644 index bf585d7..0000000 Binary files a/out/production/Robot_Factory_PR/roboter/exceptions/RobotMagicValueException.class and /dev/null differ diff --git a/out/production/Robot_Factory_PR/roboter/interfaces/Robot.class b/out/production/Robot_Factory_PR/roboter/interfaces/Robot.class deleted file mode 100644 index 914d322..0000000 Binary files a/out/production/Robot_Factory_PR/roboter/interfaces/Robot.class and /dev/null differ diff --git a/out/production/Robot_Factory_PR/roboter/interfaces/RobotControl.class b/out/production/Robot_Factory_PR/roboter/interfaces/RobotControl.class deleted file mode 100644 index 563286b..0000000 Binary files a/out/production/Robot_Factory_PR/roboter/interfaces/RobotControl.class and /dev/null differ diff --git a/out/production/Robot_Factory_PR/roboter/interfaces/RobotInstructions.class b/out/production/Robot_Factory_PR/roboter/interfaces/RobotInstructions.class deleted file mode 100644 index c7cbc45..0000000 Binary files a/out/production/Robot_Factory_PR/roboter/interfaces/RobotInstructions.class and /dev/null differ diff --git a/ui/UI.java b/ui/UI.java index 43c73a3..5504904 100644 --- a/ui/UI.java +++ b/ui/UI.java @@ -1,4 +1,7 @@ package ui; public class UI { + + + }