staging changes

main
Philipp3107 2022-12-14 09:54:18 +01:00
parent 2ec4b24942
commit 39bf2f38f5
29 changed files with 325 additions and 122 deletions

View File

@ -23,5 +23,15 @@
<SOURCES /> <SOURCES />
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component> </component>
</module> </module>

View File

@ -1,11 +1,29 @@
import domain.C3PO; import domain.C3PO;
import domain.R2D2;
import robot.exceptions.RobotException;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
C3PO Herbert = new C3PO(0, "Herbert"); C3PO Herbert = new C3PO(0, "Herbert");
R2D2 Gudrun = new R2D2(0, "Gdurun");
int[] input = {6,5,4,3,2,1}; 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 //just some testing
/*C3PO Herbert = new C3PO(0, "Herbert"); /*C3PO Herbert = new C3PO(0, "Herbert");

View File

@ -175,7 +175,11 @@ ___
___ ___
### Methods: ### Methods:
`--not set yet--` `existsSavedData():boolean`
`saveFactoryData():void -> throws`
`loadFactoryData():Object -> throws`
## robot ## robot

View File

@ -1,10 +1,20 @@
package domain; package domain;
import robot.exceptions.RobotException;
import robot.interfaces.Sorting;
public class C3PO extends RobotBasics { public class C3PO extends RobotBasics {
public C3PO(int id, String name){ public C3PO(int id, String name){
super(id, 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;
};
} }

View File

@ -1,5 +1,9 @@
package domain; package domain;
import robot.exceptions.RobotException;
import robot.exceptions.RobotIllegalStateException;
import robot.interfaces.Sorting;
public class R2D2 extends RobotBasics { public class R2D2 extends RobotBasics {
/** /**
* Constructor * 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;
};
} }

View File

@ -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 { 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());
}
} }

View File

@ -3,8 +3,8 @@ package domain;
import robot.exceptions.RobotException; import robot.exceptions.RobotException;
import robot.exceptions.RobotIllegalStateException; import robot.exceptions.RobotIllegalStateException;
import robot.interfaces.Robot; import robot.interfaces.Robot;
import robot.interfaces.RobotControl;
import robot.interfaces.RobotInstructions; import java.util.Arrays;
public class RobotBasics implements Robot { public class RobotBasics implements Robot {
@ -18,7 +18,7 @@ public class RobotBasics implements Robot {
this.power = false; this.power = false;
} }
/** /**
* @see RobotControl * @see robot.interfaces.RobotControl;
*/ */
@Override @Override
public int getId() { public int getId() {
@ -26,7 +26,7 @@ public class RobotBasics implements Robot {
} }
/** /**
* @see RobotControl * @see robot.interfaces.RobotControl;
*/ */
@Override @Override
public String getName() { public String getName() {
@ -34,7 +34,7 @@ public class RobotBasics implements Robot {
} }
/** /**
* @see RobotControl * @see robot.interfaces.RobotControl;
*/ */
@Override @Override
public void triggerPowerSwitch() { public void triggerPowerSwitch() {
@ -46,7 +46,7 @@ public class RobotBasics implements Robot {
} }
/** /**
* @see RobotControl * @see robot.interfaces.RobotControl;
*/ */
@Override @Override
public boolean isPowerOn() { 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 @Override
public String speak(int[] zahlen) throws RobotException { public String speak(int[] zahlen) throws RobotException {
if(power == true){ if(isPowerOn() == true){
String array = ""; final String[] array = {""};
for(int i = 0; i < zahlen.length; i++){ Arrays.stream(zahlen).forEach(i -> array[0] += i + ", ");
array += zahlen[i] + " "; return array[0];
}
return array;
}else{ }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 @Override
public int[] think(int[] zahlen) throws RobotException { public int[] think(int[] zahlen) throws RobotException {
return new int[0]; if(isPowerOn() == true){
return zahlen;
}else{
throw new RobotIllegalStateException(name + " is turned off");
}
} }
} }

View File

@ -23,5 +23,15 @@
<SOURCES /> <SOURCES />
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component> </component>
</module> </module>

View File

@ -17,176 +17,252 @@
# Overview # Overview
## Packages ## Packages
* [Domain](#domain) * ### [Domain](#domain-1)
* [R2D2](#-klasse-r2d2-) * [R2D2](#-classe-r2d2-)
* [R2D2Test](#-testklasse-r2d2test-) * [R2D2Test](#-testclasse-r2d2test-)
* [C3P0](#-klasse-c3po-) * [C3P0](#-classe-c3po-)
* [Robot](#-interface-robot-) * [C3POTest](#-testclasse-c3potest-)
* [RobotControl](#-interface-robotcontrol-) * [RobotBasics](#-class-robotbasics-)
* [RobotControl](#-interface-robotinstructions-) * ### [Facade](#facade-1)
* [Facade](#facade) * [Factrory](#-classe-factory-)
* [Factrory](#-klasse-factory-) * ### [Infrastructure](#infratructure-1)
* [Infrastructure](#infratructure) * [Persistenz](#-classe-persistenz-)
* [Persistenz](#-klasse-persistenz-) * ### [robot](#robot-1)
* [UI](#ui) * ### [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 ## Sidefiles
* [Main](#-klasse-main-) * [Main](#-classe-main-)
* [makefile](#-makefile-for-Git-updates-) * [makefile](#-makefile-for-Git-updates-)
## Domain ## Domain
<h2 align="center"> Klasse R2D2 </h2> <h2 align="center"> Class R2D2 </h2>
### Variables: ### Variables:
``` `--not set yet--`
private int id
private String name
private boolean power
```
___ ___
### Methods: ### Methods:
``` `public R2D2():R2D2`
public R2D2():R2D2
//implemented from interface Robotcontrol
public getId():int
public getName():String
public triggerPowerSWitch():void
public isPowerOn():boolean
```
<h2 align="center"> TestKlasse R2D2Test </h2> <h2 align="center">
TestClass R2D2Test
</h2>
### Variables: ### Variables:
```
public int id `public int id`
public String name
public R2D2 Herbert `public String name`
```
`public R2D2 Herbert`
___ ___
### Methods: ### Methods:
```
@BeforeEach
setup():void
@Test `@BeforeEach`
getId():void `setup():void`
getName():void
triggerPowerSwitch():void
iPowerOn():void
``` `@Test`
<h2 align="center"> Klasse C3PO </h2> `getId():void`
`getName():void`
`triggerPowerSwitch():void`
`iPowerOn():void`
<h2 align="center">
Class C3PO
</h2>
### Variables: ### Variables:
``` `--not set yet--`
--not set yet--
```
___ ___
### Methods: ### Methods:
``` `//construtor`
--not set yet--
```
<h2 align="center"> Interface Robot </h2> `public C3PO(): C3PO`
<h2 align="center">
TestClass C3PO
</h2>
### Variables:
`public int id`
`public String name`
`public C3PO Herbert`
___
### Methods: ### Methods:
``` `@BeforeEach`
--not set yet-- `setup():void`
```
`@Test`
`getId():void`
`getName():void`
`triggerPowerSwitch():void`
`iPowerOn():void`
<h2 align="center"> Interface RobotControl </h2>
<h2 align="center">
Class RobotBasics
</h2>
### Variables:
`private int id`
`private String name`
`private boolean power`
___
### Methods: ### Methods:
``` `public RobotBasics():RobotBasics`
--not set yet--
```
<h2 align="center"> Interface RobotInstructions </h2> `public getId():int`
### Methods: `public getName():String`
```
--not set yet--
```
`public triggerPowerSwitch():void`
`public ìsPowerOn():boolean`
`public speak():String`
`public think():int[]`
## facade ## facade
<h2 align="center"> Klasse Factory </h2> <h2 align="center"> Class Factory </h2>
### Variables: ### Variables:
``` `--not set yet--`
--not set yet--
```
___ ___
### Methods: ### Methods:
``` `--not set yet--`
--not set yet--
```
## Infrastructure ## Infrastructure
<h2 align="center"> Klasse Persistenz </h2> <h2 align="center"> Class Persistenz </h2>
### Variables: ### Variables:
``` `--not set yet--`
--not set yet--
```
___ ___
### Methods: ### Methods:
``` `existsSavedData():boolean`
--not set yet--
``` `saveFactoryData():void -> throws`
`loadFactoryData():Object -> throws`
## robot
### exceptions
<h2 align="center">
Class RobotException
</h2>
#### Methods:
`public RobotException():Exception`
<h2 align="center"> Class RobotIllegalStateException </h2>
#### Methods:
`public RobotIllegalStateException():RobotException`
<h2 align="center"> Class RobotMagicValueException </h2>
#### Methods:
`public RobotMagicValueException():RobotException`
### interfaces
<h2 align="center">
Interface Robot </h2>
#### Methods:
`--not set yet--`
<h2 align="center">
Interface RobotControl
</h2>
### Methods:
`--not set yet--`
<h2 align="center">
Interface RobotInstructions </h2>
### Methods:
`--not set yet--`
## UI ## UI
<h2 align="center"> Klasse UI </h2> <h2 align="center"> Class UI </h2>
### Variables: ### Variables:
``` `--not set yet--`
--not set yet--
```
___ ___
### Methods: ### Methods:
``` `--not set yet--`
--not set yet--
```
<h2 align="center"> Klasse Main </h2>
<h2 align="center"> Class Main </h2>
### Variables: ### Variables:
``` `--not set yet--`
--not set yet--
```
___ ___
### Methods: ### Methods:
``` `--not set yet--`
--not set yet--
```
<h2 align="center"> makefile for Git updates </h2> <h2 align="center"> makefile for Git updates </h2>
### Variables: ### Variables:
``` `--not set yet--`
--not set yet--
```
___ ___
### Methods: ### Methods:
```
update_readme: `update_readme:`
update_make:
update_all: `update_make:`
```
`update_all:`
## Aufgabe ## Aufgabe

View File

@ -1,4 +1,7 @@
package ui; package ui;
public class UI { public class UI {
} }