Updated everything. Further explanation in README
parent
ab50e72b86
commit
0f217e8d6c
|
@ -1,9 +1,11 @@
|
||||||
import domain.*;
|
import domain.*;
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
|
import ui.UI;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
UI ui = new UI("test_factory");
|
||||||
|
|
||||||
int[] input = {42,6,5,4,3,43,1};
|
int[] input = {42,6,5,4,3,43,1};
|
||||||
int[] input2 = input;
|
int[] input2 = input;
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
* [Factrory](#-classe-factory-)
|
* [Factrory](#-classe-factory-)
|
||||||
* ### [Infrastructure](#infratructure-1)
|
* ### [Infrastructure](#infratructure-1)
|
||||||
* [Persistenz](#-classe-persistenz-)
|
* [Persistenz](#-classe-persistenz-)
|
||||||
* ### [robot](#robot-1)
|
* ### [safety](#robot-1)
|
||||||
* ### [exceptions](#exceptions-1)
|
* ### [safety](#exceptions-1)
|
||||||
* [RobotException](#-class-robotexception-)
|
* [RobotException](#-class-robotexception-)
|
||||||
* [RobotIllegalStateException](#-class-robotillegalstateexception-)
|
* [RobotIllegalStateException](#-class-robotillegalstateexception-)
|
||||||
* [RobotMagicValueException](#-class-robotmagicvalueexception-)
|
* [RobotMagicValueException](#-class-robotmagicvalueexception-)
|
||||||
|
@ -199,9 +199,9 @@ ___
|
||||||
|
|
||||||
`loadFactoryData():Object -> throws`
|
`loadFactoryData():Object -> throws`
|
||||||
|
|
||||||
## robot
|
## safety
|
||||||
|
|
||||||
### exceptions
|
### safety
|
||||||
|
|
||||||
<h2 align="center">
|
<h2 align="center">
|
||||||
Class RobotException
|
Class RobotException
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package domain;
|
package domain;
|
||||||
|
|
||||||
import robot.exceptions.ExceptionStorage;
|
import safety.robot_exceptions.ExceptionStorage;
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
import robot.exceptions.robotExceptions;
|
import safety.robot_exceptions.robotExceptions;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class C3PO extends RobotBasics {
|
public class C3PO extends RobotBasics {
|
||||||
public C3PO(int id, String name){
|
public C3PO(int id, String name){
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package domain;
|
package domain;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package domain;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class Factory {
|
||||||
|
private HashMap<RobotBasics, Integer> robots = new HashMap<>();
|
||||||
|
private int c3poID = 0;
|
||||||
|
private int r2d2ID = 1000;
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
package domain;
|
package domain;
|
||||||
|
|
||||||
|
|
||||||
import robot.exceptions.ExceptionStorage;
|
import safety.robot_exceptions.ExceptionStorage;
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
import robot.exceptions.robotExceptions;
|
import safety.robot_exceptions.robotExceptions;
|
||||||
|
|
||||||
public class R2D2 extends RobotBasics {
|
public class R2D2 extends RobotBasics {
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ public class R2D2 extends RobotBasics {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotInstructions
|
* @see safety.interfaces.RobotInstructions
|
||||||
*/
|
*/
|
||||||
public int[] think(int[] input) throws RobotException {
|
public int[] think(int[] input) throws RobotException {
|
||||||
if(isPowerOn()){
|
if(isPowerOn()){
|
||||||
|
@ -32,7 +32,7 @@ public class R2D2 extends RobotBasics {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotInstructions
|
* @see safety.interfaces.RobotInstructions
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String speak(int[] input) throws RobotException {
|
public String speak(int[] input) throws RobotException {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package domain;
|
package domain;
|
||||||
|
|
||||||
import robot.exceptions.ExceptionStorage;
|
import safety.robot_exceptions.ExceptionStorage;
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
import robot.exceptions.robotExceptions;
|
import safety.robot_exceptions.robotExceptions;
|
||||||
import robot.interfaces.Robot;
|
import safety.interfaces.Robot;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -23,7 +23,7 @@ public abstract class RobotBasics implements Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotControl;
|
* @see safety.interfaces.RobotControl;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -31,7 +31,7 @@ public abstract class RobotBasics implements Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotControl;
|
* @see safety.interfaces.RobotControl;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -39,7 +39,7 @@ public abstract class RobotBasics implements Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotControl;
|
* @see safety.interfaces.RobotControl;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void triggerPowerSwitch() {
|
public void triggerPowerSwitch() {
|
||||||
|
@ -51,7 +51,7 @@ public abstract class RobotBasics implements Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotControl;
|
* @see safety.interfaces.RobotControl;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPowerOn() {
|
public boolean isPowerOn() {
|
||||||
|
@ -59,7 +59,7 @@ public abstract class RobotBasics implements Robot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see robot.interfaces.RobotControl;
|
* @see safety.interfaces.RobotControl;
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public RobotException getLastException() {
|
public RobotException getLastException() {
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package facade;
|
|
||||||
|
|
||||||
public class Factory {
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package facade;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import domain.*;
|
||||||
|
import infrastructure.Persistenz;
|
||||||
|
|
||||||
|
public class FactorySystem {
|
||||||
|
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public FactorySystem(String name){
|
||||||
|
if(Persistenz.existsSavedData(name)){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -23,5 +23,9 @@ update_interfaces:
|
||||||
git add robot/interfaces
|
git add robot/interfaces
|
||||||
git commit -m "updated interfaces"
|
git commit -m "updated interfaces"
|
||||||
git push -u origin main
|
git push -u origin main
|
||||||
|
update_ui:
|
||||||
|
git add ui/
|
||||||
|
git commit -m "updated ui"
|
||||||
|
git push -u origin main
|
||||||
fetch_git:
|
fetch_git:
|
||||||
git pull origin main
|
git pull origin main
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,5 +0,0 @@
|
||||||
package robot.exceptions;
|
|
||||||
|
|
||||||
public enum robotExceptions {
|
|
||||||
ILLEGALSTATE, MAGICVALUE, EMPTYARRAY
|
|
||||||
}
|
|
|
@ -1,9 +1,7 @@
|
||||||
/* (c) 2012 Thomas Smits */
|
/* (c) 2012 Thomas Smits */
|
||||||
package robot.interfaces;
|
package safety.interfaces;
|
||||||
|
|
||||||
|
|
||||||
import robot.exceptions.RobotException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface für Roboter.
|
* Interface für Roboter.
|
||||||
*
|
*
|
|
@ -1,5 +1,5 @@
|
||||||
package robot.interfaces;
|
package safety.interfaces;
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Das Interface repräsentiert einen einfachen Roboter mit seinen Funktionen.
|
* Das Interface repräsentiert einen einfachen Roboter mit seinen Funktionen.
|
|
@ -1,8 +1,8 @@
|
||||||
package robot.interfaces;
|
package safety.interfaces;
|
||||||
|
|
||||||
import robot.exceptions.RobotException;
|
import safety.robot_exceptions.RobotException;
|
||||||
import robot.exceptions.RobotIllegalStateException;
|
import safety.robot_exceptions.RobotIllegalStateException;
|
||||||
import robot.exceptions.RobotMagicValueException;
|
import safety.robot_exceptions.RobotMagicValueException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -1,4 +1,4 @@
|
||||||
package robot.exceptions;
|
package safety.robot_exceptions;
|
||||||
|
|
||||||
public class ArrayEmptyException extends RobotException{
|
public class ArrayEmptyException extends RobotException{
|
||||||
public ArrayEmptyException(robotExceptions type,String errorMessage){
|
public ArrayEmptyException(robotExceptions type,String errorMessage){
|
|
@ -1,4 +1,4 @@
|
||||||
package robot.exceptions;
|
package safety.robot_exceptions;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
|
@ -1,4 +1,4 @@
|
||||||
package robot.exceptions;
|
package safety.robot_exceptions;
|
||||||
|
|
||||||
public class RobotException extends Exception{
|
public class RobotException extends Exception{
|
||||||
robotExceptions currentType;
|
robotExceptions currentType;
|
||||||
|
@ -11,13 +11,7 @@ public class RobotException extends Exception{
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getMessage(robotExceptions types, String name){
|
private static String getMessage(robotExceptions types, String name){
|
||||||
String message = "";
|
return name + " " + types.getMessage();
|
||||||
switch (types){
|
|
||||||
case ILLEGALSTATE: message = name + " is turned off."; break;
|
|
||||||
case MAGICVALUE: message = name + " has an unknown error. Code 42."; break;
|
|
||||||
case EMPTYARRAY: message = name + " got an empty array."; break;
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,4 +1,4 @@
|
||||||
package robot.exceptions;
|
package safety.robot_exceptions;
|
||||||
|
|
||||||
public class RobotIllegalStateException extends RobotException{
|
public class RobotIllegalStateException extends RobotException{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package robot.exceptions;
|
package safety.robot_exceptions;
|
||||||
|
|
||||||
public class RobotMagicValueException extends RobotException {
|
public class RobotMagicValueException extends RobotException {
|
||||||
public RobotMagicValueException(robotExceptions type, String errormessage) {
|
public RobotMagicValueException(robotExceptions type, String errormessage) {
|
|
@ -0,0 +1,17 @@
|
||||||
|
package safety.robot_exceptions;
|
||||||
|
|
||||||
|
public enum robotExceptions {
|
||||||
|
ILLEGALSTATE("ist in einem illegalen Zustand"),
|
||||||
|
MAGICVALUE("Magic value"),
|
||||||
|
EMPTYARRAY("leer");
|
||||||
|
|
||||||
|
final String message;
|
||||||
|
|
||||||
|
private robotExceptions(String msg) {
|
||||||
|
this.message = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
28
ui/UI.java
28
ui/UI.java
|
@ -1,7 +1,35 @@
|
||||||
package ui;
|
package ui;
|
||||||
|
|
||||||
|
import facade.Factory;
|
||||||
|
import infrastructure.Persistenz;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class UI {
|
public class UI {
|
||||||
|
|
||||||
|
private Factory factory;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
public UI (Factory factory){
|
||||||
|
this.factory = factory;
|
||||||
|
hauptmenü();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public UI (String name){
|
||||||
|
this.name = name;
|
||||||
|
if(Persistenz.existsSavedData(name)){
|
||||||
|
try{
|
||||||
|
this.factory = (Factory) Persistenz.loadFactoryData(name);
|
||||||
|
}catch(Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
this.factory = new Factory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hauptmenü(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue