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 />
</library>
</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>
</module>

View File

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

View File

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

View File

@ -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;
};
}

View File

@ -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;
};
}

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 {
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.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");
}
}
}

View File

@ -23,5 +23,15 @@
<SOURCES />
</library>
</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>
</module>

View File

@ -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
<h2 align="center"> Klasse R2D2 </h2>
<h2 align="center"> Class R2D2 </h2>
### 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`
<h2 align="center"> TestKlasse R2D2Test </h2>
<h2 align="center">
TestClass R2D2Test
</h2>
### 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`
<h2 align="center"> Klasse C3PO </h2>
`getId():void`
`getName():void`
`triggerPowerSwitch():void`
`iPowerOn():void`
<h2 align="center">
Class C3PO
</h2>
### Variables:
```
--not set yet--
```
`--not set yet--`
___
### Methods:
```
--not set yet--
```
`//construtor`
<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:
```
--not set yet--
```
`@BeforeEach`
`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:
```
--not set yet--
```
`public RobotBasics():RobotBasics`
`public getId():int`
<h2 align="center"> Interface RobotInstructions </h2>
`public getName():String`
### Methods:
```
--not set yet--
```
`public triggerPowerSwitch():void`
`public ìsPowerOn():boolean`
`public speak():String`
`public think():int[]`
## facade
<h2 align="center"> Klasse Factory </h2>
<h2 align="center"> Class Factory </h2>
### Variables:
```
--not set yet--
```
`--not set yet--`
___
### Methods:
```
--not set yet--
```
`--not set yet--`
## Infrastructure
<h2 align="center"> Klasse Persistenz </h2>
<h2 align="center"> Class Persistenz </h2>
### Variables:
```
--not set yet--
```
`--not set yet--`
___
### Methods:
```
--not set yet--
```
`existsSavedData():boolean`
`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
<h2 align="center"> Klasse UI </h2>
<h2 align="center"> Class UI </h2>
### Variables:
```
--not set yet--
```
`--not set yet--`
___
### Methods:
```
--not set yet--
```
`--not set yet--`
<h2 align="center"> Klasse Main </h2>
<h2 align="center"> Class Main </h2>
### Variables:
```
--not set yet--
```
`--not set yet--`
___
### Methods:
```
--not set yet--
```
`--not set yet--`
<h2 align="center"> makefile for Git updates </h2>
### Variables:
```
--not set yet--
```
`--not set yet--`
___
### Methods:
```
update_readme:
update_make:
update_all:
```
`update_readme:`
`update_make:`
`update_all:`
## Aufgabe

View File

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