Updated everything. Further explanation in README

main
Philipp3107 2023-01-02 19:51:04 +01:00
parent ab50e72b86
commit 0f217e8d6c
28 changed files with 116 additions and 58 deletions

BIN
.DS_Store vendored 100644

Binary file not shown.

View File

@ -1,9 +1,11 @@
import domain.*;
import robot.exceptions.RobotException;
import safety.robot_exceptions.RobotException;
import ui.UI;
public class Main {
public static void main(String[] args) {
UI ui = new UI("test_factory");
int[] input = {42,6,5,4,3,43,1};
int[] input2 = input;

View File

@ -26,8 +26,8 @@
* [Factrory](#-classe-factory-)
* ### [Infrastructure](#infratructure-1)
* [Persistenz](#-classe-persistenz-)
* ### [robot](#robot-1)
* ### [exceptions](#exceptions-1)
* ### [safety](#robot-1)
* ### [safety](#exceptions-1)
* [RobotException](#-class-robotexception-)
* [RobotIllegalStateException](#-class-robotillegalstateexception-)
* [RobotMagicValueException](#-class-robotmagicvalueexception-)
@ -199,9 +199,9 @@ ___
`loadFactoryData():Object -> throws`
## robot
## safety
### exceptions
### safety
<h2 align="center">
Class RobotException

View File

@ -1,11 +1,8 @@
package domain;
import robot.exceptions.ExceptionStorage;
import robot.exceptions.RobotException;
import robot.exceptions.robotExceptions;
import java.util.Arrays;
import java.util.stream.Collectors;
import safety.robot_exceptions.ExceptionStorage;
import safety.robot_exceptions.RobotException;
import safety.robot_exceptions.robotExceptions;
public class C3PO extends RobotBasics {
public C3PO(int id, String name){

View File

@ -1,7 +1,7 @@
package domain;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import robot.exceptions.RobotException;
import safety.robot_exceptions.RobotException;
import static org.junit.jupiter.api.Assertions.*;

View File

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

View File

@ -1,9 +1,9 @@
package domain;
import robot.exceptions.ExceptionStorage;
import robot.exceptions.RobotException;
import robot.exceptions.robotExceptions;
import safety.robot_exceptions.ExceptionStorage;
import safety.robot_exceptions.RobotException;
import safety.robot_exceptions.robotExceptions;
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 {
if(isPowerOn()){
@ -32,7 +32,7 @@ public class R2D2 extends RobotBasics {
/**
* @see robot.interfaces.RobotInstructions
* @see safety.interfaces.RobotInstructions
*/
@Override
public String speak(int[] input) throws RobotException {

View File

@ -1,9 +1,9 @@
package domain;
import robot.exceptions.ExceptionStorage;
import robot.exceptions.RobotException;
import robot.exceptions.robotExceptions;
import robot.interfaces.Robot;
import safety.robot_exceptions.ExceptionStorage;
import safety.robot_exceptions.RobotException;
import safety.robot_exceptions.robotExceptions;
import safety.interfaces.Robot;
import java.util.Arrays;
import java.util.stream.Collectors;
@ -23,7 +23,7 @@ public abstract class RobotBasics implements Robot {
}
/**
* @see robot.interfaces.RobotControl;
* @see safety.interfaces.RobotControl;
*/
@Override
public int getId() {
@ -31,7 +31,7 @@ public abstract class RobotBasics implements Robot {
}
/**
* @see robot.interfaces.RobotControl;
* @see safety.interfaces.RobotControl;
*/
@Override
public String getName() {
@ -39,7 +39,7 @@ public abstract class RobotBasics implements Robot {
}
/**
* @see robot.interfaces.RobotControl;
* @see safety.interfaces.RobotControl;
*/
@Override
public void triggerPowerSwitch() {
@ -51,7 +51,7 @@ public abstract class RobotBasics implements Robot {
}
/**
* @see robot.interfaces.RobotControl;
* @see safety.interfaces.RobotControl;
*/
@Override
public boolean isPowerOn() {
@ -59,7 +59,7 @@ public abstract class RobotBasics implements Robot {
}
/**
* @see robot.interfaces.RobotControl;
* @see safety.interfaces.RobotControl;
*/
@Override
public RobotException getLastException() {

View File

@ -1,5 +0,0 @@
package facade;
public class Factory {
}

View File

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

View File

@ -23,5 +23,9 @@ update_interfaces:
git add robot/interfaces
git commit -m "updated interfaces"
git push -u origin main
update_ui:
git add ui/
git commit -m "updated ui"
git push -u origin main
fetch_git:
git pull origin main
git pull origin main

View File

@ -1,5 +0,0 @@
package robot.exceptions;
public enum robotExceptions {
ILLEGALSTATE, MAGICVALUE, EMPTYARRAY
}

View File

@ -1,9 +1,7 @@
/* (c) 2012 Thomas Smits */
package robot.interfaces;
package safety.interfaces;
import robot.exceptions.RobotException;
/**
* Interface für Roboter.
*

View File

@ -1,5 +1,5 @@
package robot.interfaces;
import robot.exceptions.RobotException;
package safety.interfaces;
import safety.robot_exceptions.RobotException;
/**
* Das Interface repräsentiert einen einfachen Roboter mit seinen Funktionen.

View File

@ -1,8 +1,8 @@
package robot.interfaces;
package safety.interfaces;
import robot.exceptions.RobotException;
import robot.exceptions.RobotIllegalStateException;
import robot.exceptions.RobotMagicValueException;
import safety.robot_exceptions.RobotException;
import safety.robot_exceptions.RobotIllegalStateException;
import safety.robot_exceptions.RobotMagicValueException;
/**

View File

@ -1,4 +1,4 @@
package robot.exceptions;
package safety.robot_exceptions;
public class ArrayEmptyException extends RobotException{
public ArrayEmptyException(robotExceptions type,String errorMessage){

View File

@ -1,4 +1,4 @@
package robot.exceptions;
package safety.robot_exceptions;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

View File

@ -1,4 +1,4 @@
package robot.exceptions;
package safety.robot_exceptions;
public class RobotException extends Exception{
robotExceptions currentType;
@ -11,13 +11,7 @@ public class RobotException extends Exception{
}
private static String getMessage(robotExceptions types, String name){
String message = "";
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;
return name + " " + types.getMessage();
}
@Override

View File

@ -1,4 +1,4 @@
package robot.exceptions;
package safety.robot_exceptions;
public class RobotIllegalStateException extends RobotException{

View File

@ -1,4 +1,4 @@
package robot.exceptions;
package safety.robot_exceptions;
public class RobotMagicValueException extends RobotException {
public RobotMagicValueException(robotExceptions type, String errormessage) {

View File

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

View File

@ -1,7 +1,35 @@
package ui;
import facade.Factory;
import infrastructure.Persistenz;
import java.util.Scanner;
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ü(){
}
}