Struktur geändert

main
Lukas Berens 2023-01-07 14:15:53 +01:00
parent dbb7419f1e
commit d42c1ef95e
15 changed files with 98 additions and 40 deletions

7
.classpath 100644
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="Bank-Beispiel/src"/>
<classpathentry kind="src" path="Roboter"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,20 @@
package tpe.exceptions;
import java.util.*;
import java.lang.Thread;
@SuppressWarnings("serial")
public class RobotException extends Exception {
public class MagicValueException extends Throwable {
throw new Exception("Die Zahl 42 kann nicht verarbeitet werden");
}
public RobotException(String string) {
// TODO Auto-generated constructor stub
}
public RobotException MagicValueException() throws {
}
}

View File

@ -0,0 +1,13 @@
package tpe.exceptions;
public class RobotIllegalStateException {
public boolean illegalState(boolean powerSwitch) {
if(powerSwitch=false)
{
return false;
}
else
return true;
}
}

View File

@ -1,6 +1,6 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
import tpe.exceptions.roboter.exceptions.RobotException; import tpe.exceptions.RobotException;
public class C3PO implements Robot{ public class C3PO implements Robot{

View File

@ -1,6 +1,6 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
import tpe.exceptions.roboter.exceptions.RobotException; import tpe.exceptions.RobotException;
public class Nexus6 implements RobotControl, RobotInstructions { public class Nexus6 implements RobotControl, RobotInstructions {
private static int id=19281982; private static int id=19281982;

View File

@ -1,7 +1,8 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
import java.util.*; import java.util.*;
import tpe.exceptions.roboter.exceptions.RobotException;
import tpe.exceptions.RobotException;
public class R2D2 implements Robot { public class R2D2 implements Robot {
RobotException robotexception; RobotException robotexception;

View File

@ -1,6 +1,6 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
import tpe.exceptions.roboter.exceptions.RobotException; import tpe.exceptions.RobotException;
/** /**
* Das Interface repräsentiert einen einfachen Roboter mit seinen Funktionen. * Das Interface repräsentiert einen einfachen Roboter mit seinen Funktionen.

View File

@ -1,8 +1,8 @@
package tpe.exceptions.roboter; package tpe.exceptions.roboter;
import tpe.exceptions.roboter.exceptions.RobotException; import tpe.exceptions.RobotException;
import tpe.exceptions.roboter.exceptions.RobotIllegalStateException; import tpe.exceptions.RobotIllegalStateException;
import tpe.exceptions.roboter.exceptions.RobotMagicValueException; import tpe.exceptions.RobotMagicValueException;
/** /**
* Das Interface repräsentiert den Befehlssatz eines einfachen Roboters. * Das Interface repräsentiert den Befehlssatz eines einfachen Roboters.

View File

@ -1,6 +0,0 @@
package tpe.exceptions.roboter.exceptions;
public class RobotException {
}

View File

@ -1,5 +0,0 @@
package tpe.exceptions.roboter.exceptions;
public class RobotIllegalStateException {
}

View File

@ -1,16 +0,0 @@
package tpe.exceptions.roboter.exceptions;
public class RobotMagicValueException {
public boolean invalidNumber(int[] zahlen) {
boolean error=false;
for(int i =0; i<zahlen.length;i++)
{
if(zahlen[i]==42)
error=true ;
}
return error;
}
}

View File

@ -1,5 +0,0 @@
package tpe.exceptions.roboter.ui;
public class UI {
}

View File

@ -1,4 +1,4 @@
package tpe.exceptions.roboter.facade; package tpe.facade;
import tpe.exceptions.roboter.C3PO; import tpe.exceptions.roboter.C3PO;
import tpe.exceptions.roboter.R2D2; import tpe.exceptions.roboter.R2D2;
@ -6,6 +6,11 @@ import tpe.exceptions.roboter.R2D2;
public class RobotFactory { public class RobotFactory {
private R2D2 r2d2; private R2D2 r2d2;
private C3PO c3po; private C3PO c3po;
enum RobotType{
R2D2,
C3PO,
NEXUS6
}
public int constructRobot() { public int constructRobot() {
} }

View File

@ -0,0 +1,39 @@
package tpe.infrastructure;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
public class Persistenz {
private static final String Robot_DATEI = "-robot-data.ser";
public static boolean checkDataSaved(String name) {
return new File(name + Robot_DATEI).exists();
}
public static boolean deleteRobotData(String name) throws FileNotFoundException, IOException
{
File file = new File("C:\\Users\\Lukas Berens\\git\\RoboterFabrik\\"+name+"-robot-data.ser");
return file.delete();
}
public static void saveRobotData(Object robot, String name) throws Exception {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(name + Robot_DATEI));
oos.writeObject(robot);
oos.close();
}
public static Object loadRobotData(String name) throws Exception {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(name + Robot_DATEI));
Object robot = ois.readObject();
ois.close();
return robot;
}
}

View File

@ -0,0 +1,5 @@
package tpe.ui;
public class UI {
}