Projekt Alien Defence von Schick&Kannix eingekauft
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Vector;
|
||||
|
||||
import toDo.User;
|
||||
|
||||
public class Attempt {
|
||||
|
||||
// Attribute
|
||||
private User user;
|
||||
private Level level;
|
||||
private int placement;
|
||||
private double hitsShots;
|
||||
private double hitsTargets;
|
||||
private double reactionDuration;
|
||||
private double highscorePoints;
|
||||
private LocalDateTime datetime;
|
||||
|
||||
// Konstruktor
|
||||
public Attempt(int place, Level level, double hitsShots, double hitsTargets, double reactionDuration,
|
||||
double highscoreFormula, User user, LocalDateTime datetime) {
|
||||
super();
|
||||
this.placement = place;
|
||||
this.level = level;
|
||||
this.reactionDuration = reactionDuration;
|
||||
this.highscorePoints = highscoreFormula;
|
||||
this.user = user;
|
||||
this.hitsShots = hitsShots;
|
||||
this.hitsTargets = hitsTargets;
|
||||
this.datetime = datetime;
|
||||
}
|
||||
|
||||
public Vector<String> getRowVector() {
|
||||
Vector<String> v = new Vector<String>(8);
|
||||
v.addElement(String.valueOf(this.placement));
|
||||
v.addElement(this.user.getFirst_name() + " " + this.user.getSur_name());
|
||||
v.addElement(this.datetime.getDayOfMonth() +"."+this.datetime.getMonthValue() + "." + this.datetime.getYear());;
|
||||
v.addElement(this.datetime.getHour() + ":" + this.datetime.getMinute());
|
||||
v.addElement(String.valueOf((int) this.hitsTargets));
|
||||
v.addElement(String.valueOf((int) this.hitsShots));
|
||||
v.addElement(String.valueOf((int) this.reactionDuration));
|
||||
v.addElement(String.valueOf((int) this.highscorePoints));
|
||||
return v;
|
||||
}
|
||||
|
||||
public Level getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package model;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Hitbox {
|
||||
private Point point;
|
||||
private int width;
|
||||
private int height;
|
||||
public static final int MAXWIDTH = 1200;
|
||||
public static final int MAXHEIGHT = 1000;
|
||||
private static Random rand = new Random();
|
||||
|
||||
public Hitbox() {
|
||||
this.point = new Point();
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
}
|
||||
|
||||
public Hitbox(int x, int y, int breite, int hoehe) {
|
||||
super();
|
||||
this.point = new Point(x, y);
|
||||
this.setWidth(breite);
|
||||
this.setHeight(hoehe);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.point.getX();
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.point.setX(x);
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.point.getY();
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.point.setY(y);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = Math.abs(width);
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = Math.abs(height);
|
||||
}
|
||||
|
||||
public boolean contains(Point p) {
|
||||
return contains(p.getX(), p.getY());
|
||||
}
|
||||
|
||||
public boolean contains(int x, int y) {
|
||||
return this.point.getX() <= x && x <= this.point.getX() + this.width && this.point.getY() <= y
|
||||
&& y <= this.point.getY() + this.height;
|
||||
}
|
||||
|
||||
public boolean contains(Hitbox hitbox) {
|
||||
Point upperleft = new Point(hitbox.getX(), hitbox.getY());
|
||||
Point lowerright = new Point(hitbox.getX() + hitbox.getWidth(), hitbox.getY() + hitbox.getHeight());
|
||||
return contains(upperleft) && contains(lowerright);
|
||||
}
|
||||
|
||||
public static Hitbox generateRandomHitbox() {
|
||||
int x = rand.nextInt(MAXWIDTH + 1);
|
||||
int y = rand.nextInt(MAXHEIGHT + 1);
|
||||
int width = rand.nextInt(MAXWIDTH - x + 1);
|
||||
int height = rand.nextInt(MAXHEIGHT - y + 1);
|
||||
return new Hitbox(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Hitbox [x=" + this.point.getX() + ", y=" + this.point.getY() + ", width=" + width + ", height=" + height
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Level {
|
||||
|
||||
/** unique value */
|
||||
private int level_id;
|
||||
/** name of that level */
|
||||
private String name;
|
||||
/** List of Targets */
|
||||
private List<Target> targets;
|
||||
/** duration a level lasts im ms */
|
||||
private long duration;
|
||||
/** default duration for a level is 90s */
|
||||
public final long DEFAULT_DURATION = 90000L;
|
||||
/** path to background image */
|
||||
private String backgroundImage;
|
||||
|
||||
public Level() {
|
||||
this.targets = new ArrayList<Target>(100);
|
||||
this.name = "unnamed";
|
||||
this.duration = DEFAULT_DURATION;
|
||||
this.backgroundImage = "background_1.jpg";
|
||||
}
|
||||
|
||||
public Level(int level_id) {
|
||||
this();
|
||||
this.level_id = level_id;
|
||||
}
|
||||
|
||||
public int getLevel_id() {
|
||||
return this.level_id;
|
||||
}
|
||||
|
||||
public void setLevel_id(int level_id) {
|
||||
this.level_id = level_id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Target> getTargets() {
|
||||
return this.targets;
|
||||
}
|
||||
|
||||
public void setTargets(List<Target> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getBackgroundImage() {
|
||||
return backgroundImage;
|
||||
};
|
||||
|
||||
public void setBackgroundImage(String backgroundImage) {
|
||||
this.backgroundImage = backgroundImage;
|
||||
}
|
||||
|
||||
public String[][] getTargetsAsTableModel() {
|
||||
String[][] result = new String[this.targets.size()][];
|
||||
int i = 0;
|
||||
for (Target t : this.targets) {
|
||||
result[i++] = t.getData();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String[] getData() {
|
||||
return new String[] { "" + this.level_id, this.name, this.backgroundImage, "" + this.targets.size(),
|
||||
"" + this.duration };
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Level [level_id=" + level_id + ", name=" + name + ", duration=" + duration + ", backgroundImage="
|
||||
+ backgroundImage + ", targets=" + targets + "]";
|
||||
}
|
||||
|
||||
/** use this Level only for test porposes */
|
||||
public static Level getDefaultLevel() {
|
||||
Level level = new Level();
|
||||
// Objekte des Levels hier eintragen
|
||||
level.targets.add(new Target(100, 100, 75, 150, 0, 500000, "lemon.png"));
|
||||
level.targets.add(new Target(200, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(300, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(400, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(500, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(600, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(700, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(800, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(900, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1000, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1100, 100, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(100, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(200, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(300, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(400, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(500, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(600, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(700, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(800, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(900, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1000, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1100, 300, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(100, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(200, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(300, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(400, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(500, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(600, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(700, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(800, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(900, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1000, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1100, 500, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(100, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(200, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(300, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(400, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(500, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(600, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(700, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(800, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(900, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1000, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.targets.add(new Target(1100, 700, 75, 150, 0, 500000, "ballon.png"));
|
||||
level.duration = 25000L;
|
||||
level.name = "DefaultTestLevel 001";
|
||||
level.level_id = 1;
|
||||
return level;
|
||||
}
|
||||
|
||||
public static String[] getLevelDescriptions() {
|
||||
return new String[] { "Nr.", "Name", "Hintergrund", "Targets", "Dauer" };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package model;
|
||||
|
||||
public class Point {
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
public Point() {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
}
|
||||
|
||||
public Point(int x, int y) {
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public boolean equals(Point p) {
|
||||
return this.x == p.getX() && this.y == p.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Punkt [x=" + x + ", y=" + y + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package model;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Target {
|
||||
|
||||
private int target_id;
|
||||
/** the area of a target */
|
||||
private Hitbox hitbox;
|
||||
/** time a target appears after game begins */
|
||||
private long time;
|
||||
/** time a target is able to hit */
|
||||
private long duration;
|
||||
private boolean hit;
|
||||
private String imageAddress;
|
||||
|
||||
/** image of target */
|
||||
|
||||
public Target() {
|
||||
super();
|
||||
this.target_id = 0;
|
||||
this.hitbox = new Hitbox(100, 100, 150, 50);
|
||||
this.time = 1000;
|
||||
this.duration = Long.MAX_VALUE;
|
||||
this.setHit(false);
|
||||
this.setImageAddress("ufo_1.png");
|
||||
}
|
||||
|
||||
public Target(int x, int y, int width, int height, long time, long duration, String image) {
|
||||
super();
|
||||
this.target_id = 0;
|
||||
this.hitbox = new Hitbox(x, y, width, height);
|
||||
this.time = time;
|
||||
this.duration = duration;
|
||||
this.setHit(false);
|
||||
this.setImageAddress(image);
|
||||
}
|
||||
|
||||
public Target(Hitbox hitbox, long time, long duration) {
|
||||
super();
|
||||
this.target_id = 0;
|
||||
this.hitbox = hitbox;
|
||||
this.time = time;
|
||||
this.duration = duration;
|
||||
this.setHit(false);
|
||||
}
|
||||
|
||||
public int getTarget_id() {
|
||||
return target_id;
|
||||
}
|
||||
|
||||
public void setTarget_id(int target_id) {
|
||||
this.target_id = target_id;
|
||||
}
|
||||
|
||||
public Hitbox getHitbox() {
|
||||
return hitbox;
|
||||
}
|
||||
|
||||
public void setHitbox(Hitbox hitbox) {
|
||||
this.hitbox = hitbox;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public boolean isHit() {
|
||||
return hit;
|
||||
}
|
||||
|
||||
public void setHit(boolean hit) {
|
||||
this.hit = hit;
|
||||
}
|
||||
|
||||
public String getImageAddress() {
|
||||
return imageAddress;
|
||||
}
|
||||
|
||||
public void setImageAddress(String imageAdress) {
|
||||
this.imageAddress = imageAdress;
|
||||
}
|
||||
|
||||
public static Target getRandomTarget(int screenResolution_X, int screenResolution_Y) {
|
||||
Random rand = new Random();
|
||||
return new Target(rand.nextInt(screenResolution_X - 50), rand.nextInt(screenResolution_Y - 50), 350, 129, 0,
|
||||
90000, "ufo_4.png");
|
||||
}
|
||||
|
||||
public String[] getData() {
|
||||
return new String[] { this.target_id + "", this.hitbox.getX() + "", this.hitbox.getY() + "",
|
||||
this.hitbox.getWidth() + "", this.hitbox.getHeight() + "", this.getImageAddress(), this.getTime() + "",
|
||||
this.getDuration() + "" };
|
||||
}
|
||||
|
||||
public static String[] getTableDescriptions() {
|
||||
return new String[] { "Nr.", "X", "Y", "Breite", "Hühe", "Bild", "Startzeit", "Dauer" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Target [target_id=" + target_id + ", hitbox=" + hitbox + ", time=" + time + ", duration=" + duration
|
||||
+ ", hit=" + hit + ", imageAddress=" + imageAddress + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package model.persistence;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import model.Level;
|
||||
|
||||
public interface IAttemptPersistance {
|
||||
|
||||
int createHighscoreEntry(int F_user_id, int F_level_id, int shots, int hits, long reaction_time);
|
||||
int getPlayerPosition();
|
||||
Vector<Vector<String>> getAllAttemptsPerLevel(Level level, int game_id);
|
||||
//no update needed
|
||||
void deleteHighscore(int level_id);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package model.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import model.Level;
|
||||
|
||||
public interface ILevelPersistance {
|
||||
|
||||
/**
|
||||
* legt in der Datenbank ein neues Level an
|
||||
*
|
||||
* @return level_id für das neue Level
|
||||
*/
|
||||
int createLevel(String levelname, String backgroundUrl, long duration);
|
||||
|
||||
/**
|
||||
* gibt alle Level aus der Datenbank als Liste zurück
|
||||
*
|
||||
* @return Liste aller Level
|
||||
*/
|
||||
List<Level> readAllLevel();
|
||||
|
||||
/**
|
||||
* aktualisiert die Daten eines Levels
|
||||
*
|
||||
* @param lvl
|
||||
* ein Levelobjekt
|
||||
*/
|
||||
void updateLevel(Level lvl);
|
||||
|
||||
/**
|
||||
* lüscht ein Level aus der Datenbank
|
||||
*
|
||||
* @param P_level_id
|
||||
*/
|
||||
void deleteLevel(int level_id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package model.persistence;
|
||||
|
||||
public interface IPersistance {
|
||||
|
||||
IAttemptPersistance getAttemptPersistance();
|
||||
ILevelPersistance getLevelPersistance();
|
||||
ITargetPersistance getTargetPersistance();
|
||||
IUserPersistance getUserPersistance();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package model.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import model.Target;
|
||||
|
||||
public interface ITargetPersistance {
|
||||
|
||||
int createTarget(Target target, int level_id, int image_id);
|
||||
|
||||
List<Target> readAllTargetsPerLevel(int level_id);
|
||||
|
||||
void updateTarget(Target target);
|
||||
|
||||
void deleteTarget(int target_id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package model.persistence;
|
||||
|
||||
import toDo.User;
|
||||
|
||||
public interface IUserPersistance {
|
||||
|
||||
User readUser(String username);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package model.persistenceDB;
|
||||
|
||||
public class AccessDB {
|
||||
|
||||
// Attribute
|
||||
private String dbName;
|
||||
private String user;
|
||||
private String password;
|
||||
private String url;
|
||||
|
||||
// Konstruktor
|
||||
public AccessDB() {
|
||||
this.url = "jdbc:mysql://localhost:3306/";
|
||||
this.dbName = "alien_defence";
|
||||
this.user = "root";
|
||||
this.password = "";
|
||||
}
|
||||
|
||||
// Getter und Setter
|
||||
public String getDbName() {
|
||||
return dbName;
|
||||
}
|
||||
|
||||
public void setDbName(String dbName) {
|
||||
this.dbName = dbName;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getFullURL() {
|
||||
return this.url + this.dbName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package model.persistenceDB;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Vector;
|
||||
|
||||
import model.Attempt;
|
||||
import model.Level;
|
||||
import model.persistence.IAttemptPersistance;
|
||||
import toDo.User;
|
||||
|
||||
public class AttemptDB implements IAttemptPersistance {
|
||||
|
||||
// Attribute
|
||||
private AccessDB dbAccess;
|
||||
private int playerPosition = -100000;
|
||||
|
||||
// Konstuktor
|
||||
public AttemptDB(AccessDB dbAccess) {
|
||||
this.dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
// Eintrag des Spiels in die Highscore wird vorgenommen - Aufgerufen wird von
|
||||
// der Klasse GameController
|
||||
public int createHighscoreEntry(int F_user_id, int F_level_id, int shots, int hits, long reaction_time) {
|
||||
String sql = "INSERT INTO attempts (F_user_id, F_level_id, shots, hits, reaction_time, date, time)"
|
||||
+ " values (?, ?, ?, ?, ?, ?, ?)";
|
||||
int last_inserted_id = 0;
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword());
|
||||
PreparedStatement statement = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);) {
|
||||
|
||||
// Aktuelle Datum und Uhrzeit holen und in Strings speichern
|
||||
LocalDate datum = LocalDate.now(); // Erstellt Datum-Objekt heute
|
||||
LocalTime time = LocalTime.now();
|
||||
String now = time.getHour() + ":" + time.getMinute() + ":" + time.getSecond();
|
||||
|
||||
statement.setInt(1, F_user_id);
|
||||
statement.setInt(2, F_level_id);
|
||||
statement.setInt(3, shots);
|
||||
statement.setInt(4, hits);
|
||||
statement.setLong(5, reaction_time);
|
||||
statement.setString(6, datum.toString());
|
||||
statement.setString(7, now);
|
||||
|
||||
statement.execute();
|
||||
|
||||
ResultSet rs = statement.getGeneratedKeys(); // Letzte eingtragene ID
|
||||
if (rs.next()) {
|
||||
last_inserted_id = rs.getInt(1);
|
||||
}
|
||||
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
return last_inserted_id;
|
||||
}
|
||||
|
||||
public Vector<Vector<String>> getAllAttemptsPerLevel(Level level, int game_id) {
|
||||
Vector<Vector<String>> vecTests = null;
|
||||
String url = dbAccess.getUrl() + dbAccess.getDbName();
|
||||
|
||||
String highscoreFormula = "(hits / targets * 1000)*0.4 + (hits / shots * 1000)*0.2 + (1000 - (reaction_time / sum_duration * 1000))*0.4";
|
||||
|
||||
String query = "SELECT P_attempt_id, targets, shots, hits, reaction_time, first_name, sur_name, date, time, (hits / targets * 1000) AS hitsTargets, (hits / shots * 1000) AS hitsShots, (1000 - (reaction_time / sum_duration * 1000)) AS reactionDuration,"
|
||||
+ highscoreFormula + "AS highscoreFormula FROM "
|
||||
+ "(SELECT F_level_id, COUNT(P_target_id) AS targets, SUM(duration ) AS sum_duration FROM `targets` WHERE F_level_id = "
|
||||
+ level.getLevel_id() + ") AS count_targets INNER JOIN "
|
||||
+ "attempts ON attempts.F_level_id = count_targets.F_level_id INNER JOIN "
|
||||
+ "users ON P_user_id = F_user_id ORDER BY highscoreFormula DESC, reactionDuration DESC";
|
||||
|
||||
try {
|
||||
Connection con = DriverManager.getConnection(url, dbAccess.getUser(), dbAccess.getPassword());
|
||||
Statement stmt = con.createStatement();
|
||||
ResultSet results = stmt.executeQuery(query);
|
||||
vecTests = getVecTest(level, game_id, results);
|
||||
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
return vecTests;
|
||||
}
|
||||
|
||||
public int getPlayerPosition() {
|
||||
return this.playerPosition;
|
||||
}
|
||||
|
||||
// 2 Diese Methode wird vom Konstruktor aufgerufen.
|
||||
// Daten aus der Datenbank werden in einem zweidimensionalen Vector gespeichert.
|
||||
private Vector<Vector<String>> getVecTest(Level level, int gameId, ResultSet results) {
|
||||
|
||||
Vector<Vector<String>> vecTests = new Vector<Vector<String>>();
|
||||
try {
|
||||
int nummerierung = 0;
|
||||
while (results.next()) {
|
||||
|
||||
nummerierung++;
|
||||
|
||||
//Markierung des Spielers für Highscoreansicht
|
||||
//TODO Verstoü gegen 3 Schichtenarchitektur beheben
|
||||
if (results.getInt("P_attempt_id") == gameId)
|
||||
this.playerPosition = nummerierung - 1;
|
||||
|
||||
LocalDate date = results.getDate("date").toLocalDate();
|
||||
User user = new User();
|
||||
user.setFirst_name(results.getString("first_name"));
|
||||
user.setSur_name(results.getString("sur_name"));
|
||||
LocalDateTime dateTime = date.atTime(results.getTime("time").toLocalTime());
|
||||
Attempt tmp = new Attempt(nummerierung, level, results.getDouble("hitsShots"),
|
||||
results.getDouble("hitsTargets"), results.getInt("reactionDuration"),
|
||||
results.getInt("highscoreFormula"), user, dateTime);
|
||||
|
||||
Vector<String> v = tmp.getRowVector();
|
||||
vecTests.add(v);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
return vecTests;
|
||||
}
|
||||
|
||||
// lüscht alle Eintrüge
|
||||
public void deleteHighscore(int level_id) {
|
||||
|
||||
String url = dbAccess.getFullURL();
|
||||
try {
|
||||
|
||||
Connection con = DriverManager.getConnection(url, dbAccess.getUser(), dbAccess.getPassword());
|
||||
|
||||
String query = "DELETE FROM attempts WHERE F_level_id = ?";
|
||||
|
||||
PreparedStatement preparedStmt = con.prepareStatement(query);
|
||||
preparedStmt.setInt(1, level_id);
|
||||
|
||||
preparedStmt.execute();
|
||||
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package model.persistenceDB;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import model.Level;
|
||||
import model.persistence.ILevelPersistance;
|
||||
import model.persistence.ITargetPersistance;
|
||||
|
||||
public class LevelDB implements ILevelPersistance {
|
||||
|
||||
private AccessDB dbAccess;
|
||||
|
||||
public LevelDB(AccessDB dbAccess) {
|
||||
this.dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public int createLevel(String levelname, String backgroundUrl, long duration) {
|
||||
String sql = "INSERT INTO levels (name, background, duration) VALUES (?, ?, ?);";
|
||||
|
||||
int lastKey = -1;
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword());
|
||||
PreparedStatement statement = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);) {
|
||||
|
||||
statement.setString(1, levelname);
|
||||
statement.setString(2, backgroundUrl);
|
||||
statement.setLong(3, duration);
|
||||
|
||||
statement.execute();
|
||||
|
||||
ResultSet generatedKeys = statement.getGeneratedKeys();
|
||||
if (generatedKeys.next()) {
|
||||
lastKey = generatedKeys.getInt(1);
|
||||
}
|
||||
generatedKeys.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return lastKey;
|
||||
}
|
||||
|
||||
public List<Level> readAllLevel() {
|
||||
String sql = "SELECT * FROM levels ORDER BY P_level_id;";
|
||||
List<Level> allLevels = new Vector<Level>();
|
||||
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword());
|
||||
Statement statement = con.createStatement();
|
||||
ResultSet rs = statement.executeQuery(sql)) {
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
Level level = new Level();
|
||||
level.setLevel_id(rs.getInt("P_level_id")); // ID von Level
|
||||
level.setName(rs.getString("name")); // Name von Level
|
||||
level.setDuration(rs.getInt("duration")); // Dauer von Level
|
||||
level.setBackgroundImage(rs.getString("background")); // Hintergrundsbild
|
||||
|
||||
// Targets auslesen und dem Level hinzufügen
|
||||
ITargetPersistance targetDB = new TargetDB(this.dbAccess);
|
||||
|
||||
level.setTargets(targetDB.readAllTargetsPerLevel(level.getLevel_id()));
|
||||
|
||||
allLevels.add(level);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.getMessage();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return allLevels;
|
||||
}
|
||||
|
||||
public void updateLevel(Level lvl) {
|
||||
String sql = "UPDATE levels SET name = ?, background = ?, duration = ? WHERE p_level_id = ?;";
|
||||
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword()); PreparedStatement statement = con.prepareStatement(sql)) {
|
||||
|
||||
statement.setString(1, lvl.getName());
|
||||
statement.setString(2, lvl.getBackgroundImage());
|
||||
statement.setLong(3, lvl.getDuration());
|
||||
statement.setInt(4, lvl.getLevel_id());
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteLevel(int level_id) {
|
||||
String sql = "DELETE FROM levels WHERE P_level_id = " + level_id + ";";
|
||||
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword()); Statement statement = con.createStatement()) {
|
||||
|
||||
statement.executeUpdate(sql);
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package model.persistenceDB;
|
||||
|
||||
import model.persistence.IAttemptPersistance;
|
||||
import model.persistence.ILevelPersistance;
|
||||
import model.persistence.IPersistance;
|
||||
import model.persistence.ITargetPersistance;
|
||||
import model.persistence.IUserPersistance;
|
||||
import toDo.UserDB;
|
||||
|
||||
public class PersistanceDB implements IPersistance{
|
||||
|
||||
private LevelDB levelDB;
|
||||
private UserDB userDB;
|
||||
private AttemptDB attemptDB;
|
||||
private TargetDB targetDB;
|
||||
|
||||
public PersistanceDB() {
|
||||
AccessDB dbAccess = new AccessDB();
|
||||
this.levelDB = new LevelDB(dbAccess);
|
||||
this.userDB = new UserDB(dbAccess);
|
||||
this.attemptDB = new AttemptDB(dbAccess);
|
||||
this.targetDB = new TargetDB(dbAccess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAttemptPersistance getAttemptPersistance() {
|
||||
return this.attemptDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILevelPersistance getLevelPersistance() {
|
||||
return this.levelDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITargetPersistance getTargetPersistance() {
|
||||
return this.targetDB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUserPersistance getUserPersistance() {
|
||||
return this.userDB;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package model.persistenceDB;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import model.Hitbox;
|
||||
import model.Target;
|
||||
import model.persistence.ITargetPersistance;
|
||||
|
||||
public class TargetDB implements ITargetPersistance {
|
||||
private AccessDB dbAccess;
|
||||
|
||||
public TargetDB(AccessDB dbAccess) {
|
||||
super();
|
||||
if (dbAccess != null)
|
||||
this.dbAccess = dbAccess;
|
||||
else
|
||||
this.dbAccess = new AccessDB();
|
||||
}
|
||||
|
||||
public int createTarget(Target target, int level_id, int image_id) {
|
||||
String sql = "INSERT INTO targets (F_level_id, image_address, x_position, y_position, width, height, time, duration) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
|
||||
int lastKey = -1;
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword());
|
||||
PreparedStatement statement = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);) {
|
||||
|
||||
statement.setInt(1, level_id);
|
||||
statement.setString(2, target.getImageAddress());
|
||||
statement.setInt(3, target.getHitbox().getX());
|
||||
statement.setInt(4, target.getHitbox().getY());
|
||||
statement.setInt(5, target.getHitbox().getWidth());
|
||||
statement.setInt(6, target.getHitbox().getHeight());
|
||||
statement.setLong(7, target.getTime());
|
||||
statement.setLong(8, target.getDuration());
|
||||
statement.execute();
|
||||
|
||||
ResultSet generatedKeys = statement.getGeneratedKeys();
|
||||
if (generatedKeys.next()) {
|
||||
lastKey = generatedKeys.getInt(1);
|
||||
}
|
||||
generatedKeys.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return lastKey;
|
||||
}
|
||||
|
||||
public List<Target> readAllTargetsPerLevel(int level_id) {
|
||||
String sql = "SELECT * FROM targets WHERE F_level_id = ? ORDER BY P_target_id;";
|
||||
List<Target> alltargets = new Vector<Target>();
|
||||
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword()); PreparedStatement statement = con.prepareStatement(sql)) {
|
||||
|
||||
statement.setInt(1, level_id);
|
||||
|
||||
ResultSet rs = statement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
Target target = new Target();
|
||||
target.setTarget_id(rs.getInt("P_target_id"));
|
||||
target.setHitbox(new Hitbox(rs.getInt("x_position"), rs.getInt("y_position"), rs.getInt("width"),
|
||||
rs.getInt("height")));
|
||||
target.setTime(rs.getLong("time"));
|
||||
target.setDuration(rs.getLong("duration"));
|
||||
target.setImageAddress(rs.getString("image_address"));
|
||||
|
||||
alltargets.add(target);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.getMessage();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return alltargets;
|
||||
}
|
||||
|
||||
public void updateTarget(Target target) {
|
||||
String sql = "UPDATE targets SET x_position = ?, y_position = ?, width = ?, height = ?, time = ?, duration = ?, image_address = ? WHERE P_target_id = ?;";
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword()); PreparedStatement statement = con.prepareStatement(sql)) {
|
||||
|
||||
statement.setInt(1, target.getHitbox().getX());
|
||||
statement.setInt(2, target.getHitbox().getY());
|
||||
statement.setInt(3, target.getHitbox().getWidth());
|
||||
statement.setInt(4, target.getHitbox().getHeight());
|
||||
statement.setLong(5, target.getTime());
|
||||
statement.setLong(6, target.getDuration());
|
||||
statement.setString(7, target.getImageAddress());
|
||||
statement.setInt(8, target.getTarget_id());
|
||||
statement.executeUpdate();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTarget(int target_id) {
|
||||
String sql = "DELETE FROM targets WHERE P_target_id = " + target_id + ";";
|
||||
|
||||
try (Connection con = DriverManager.getConnection(this.dbAccess.getFullURL(), this.dbAccess.getUser(),
|
||||
this.dbAccess.getPassword()); Statement statement = con.createStatement()) {
|
||||
statement.executeUpdate(sql);
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package model.persistenceDummy;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import model.Level;
|
||||
import model.persistence.IAttemptPersistance;
|
||||
|
||||
/**
|
||||
* Klasse mit Dummywerten zum Testen der View und des Controllers
|
||||
* @author Tim Tenbusch
|
||||
*
|
||||
*/
|
||||
public class AttemptDummy implements IAttemptPersistance{
|
||||
|
||||
public int createHighscoreEntry(int F_user_id, int F_level_id, int shots, int hits, long reaction_time) {
|
||||
// fleiüig speichern
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Vector<Vector<String>> getAllAttemptsPerLevel(Level level, int game_id) {
|
||||
Vector<Vector<String>> highscore = new Vector<Vector<String>>();
|
||||
Vector<String> eintrag1 = new Vector<String>();
|
||||
Vector<String> eintrag2 = new Vector<String>();
|
||||
eintrag1.addElement("1");
|
||||
eintrag2.addElement("2");
|
||||
eintrag1.addElement("Dummy Persistenz");
|
||||
eintrag2.addElement("Vorname Nachname");
|
||||
eintrag1.addElement("17.02.2021");
|
||||
eintrag2.addElement("18.02.2021");
|
||||
eintrag1.addElement("15:21");
|
||||
eintrag2.addElement("17:01");
|
||||
eintrag1.addElement("7");
|
||||
eintrag2.addElement("9");
|
||||
eintrag1.addElement("421");
|
||||
eintrag2.addElement("13");
|
||||
eintrag1.addElement("250");
|
||||
eintrag2.addElement("270");
|
||||
eintrag1.addElement("356");
|
||||
eintrag2.addElement("481");
|
||||
highscore.add(eintrag1);
|
||||
highscore.add(eintrag2);
|
||||
return highscore;
|
||||
}
|
||||
|
||||
public int getPlayerPosition() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void deleteHighscore(int level_id) {
|
||||
//Omnomnom Anfrage gefressen
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package model.persistenceDummy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import model.Level;
|
||||
import model.Target;
|
||||
import model.persistence.ILevelPersistance;
|
||||
|
||||
public class LevelDummy implements ILevelPersistance {
|
||||
|
||||
public int createLevel(String levelname, String backgroundUrl, long duration) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public List<Level> readAllLevel() {
|
||||
List<Level> levels = new ArrayList<Level>();
|
||||
Level level1 = new Level();
|
||||
level1.setLevel_id(1);
|
||||
level1.setName("Level 1");
|
||||
level1.setBackgroundImage("background_1.jpg");
|
||||
level1.setDuration(10000);
|
||||
List<Target> targets = new ArrayList<Target>();
|
||||
Target t1 = new Target(100, 100, 150, 50, 1000, 2000, "ufo_1.png");
|
||||
targets.add(t1);
|
||||
Target t2 = new Target(5, 100, 150, 50, 2000, 2000, "ufo_2.png");
|
||||
targets.add(t2);
|
||||
Target t3 = new Target(800, 800, 150, 50, 3000, 2000, "ufo_3.png");
|
||||
targets.add(t3);
|
||||
Target t4 = new Target(600, 400, 150, 50, 4000, 2000, "ufo_4.png");
|
||||
targets.add(t4);
|
||||
Target t5 = new Target(220, 400, 150, 50, 5000, 2000, "ufo_5.png");
|
||||
targets.add(t5);
|
||||
|
||||
level1.setTargets(targets);
|
||||
levels.add(level1);
|
||||
Level level2 = new Level();
|
||||
level2.setLevel_id(2);
|
||||
level2.setName("Level 2");
|
||||
level2.setBackgroundImage("background_2.jpg");
|
||||
level2.setDuration(5000);
|
||||
level2.setTargets(targets);
|
||||
levels.add(level2);
|
||||
Level level3 = new Level();
|
||||
level3.setLevel_id(3);
|
||||
level3.setName("Level 3");
|
||||
level3.setBackgroundImage("background_10.jpg");
|
||||
level3.setDuration(10000);
|
||||
level3.setTargets(targets);
|
||||
levels.add(level3);
|
||||
return levels;
|
||||
}
|
||||
|
||||
public void updateLevel(Level lvl) {
|
||||
|
||||
}
|
||||
|
||||
public void deleteLevel(int level_id) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package model.persistenceDummy;
|
||||
|
||||
import model.persistence.IAttemptPersistance;
|
||||
import model.persistence.ILevelPersistance;
|
||||
import model.persistence.IPersistance;
|
||||
import model.persistence.ITargetPersistance;
|
||||
import model.persistence.IUserPersistance;
|
||||
|
||||
public class PersistanceDummy implements IPersistance{
|
||||
|
||||
private LevelDummy levelDummy;
|
||||
private UserDummy userDummy;
|
||||
private AttemptDummy attemptDummy;
|
||||
private TargetDummy targetDummy;
|
||||
|
||||
public PersistanceDummy() {
|
||||
|
||||
this.levelDummy = new LevelDummy();
|
||||
this.userDummy = new UserDummy();
|
||||
this.attemptDummy = new AttemptDummy();
|
||||
this.targetDummy = new TargetDummy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAttemptPersistance getAttemptPersistance() {
|
||||
return this.attemptDummy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILevelPersistance getLevelPersistance() {
|
||||
return this.levelDummy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITargetPersistance getTargetPersistance() {
|
||||
return this.targetDummy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUserPersistance getUserPersistance() {
|
||||
return this.userDummy;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package model.persistenceDummy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import model.Target;
|
||||
import model.persistence.ITargetPersistance;
|
||||
|
||||
public class TargetDummy implements ITargetPersistance {
|
||||
|
||||
public int createTarget(Target target, int level_id, int image_id) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public List<Target> readAllTargetsPerLevel(int level_id) {
|
||||
List<Target> targets = new ArrayList<Target>();
|
||||
Target t1 = new Target(100, 100, 150, 50, 1000, 2000, "ufo_1.png");
|
||||
targets.add(t1);
|
||||
Target t2 = new Target(5, 100, 150, 50, 2000, 2000, "ufo_2.png");
|
||||
targets.add(t2);
|
||||
Target t3 = new Target(800, 800, 150, 50, 3000, 2000, "ufo_3.png");
|
||||
targets.add(t3);
|
||||
Target t4 = new Target(600, 400, 150, 50, 4000, 2000, "ufo_4.png");
|
||||
targets.add(t4);
|
||||
Target t5 = new Target(220, 400, 150, 50, 5000, 2000, "ufo_5.png");
|
||||
targets.add(t5);
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void updateTarget(Target target) {
|
||||
|
||||
}
|
||||
|
||||
public void deleteTarget(int target_id) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package model.persistenceDummy;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import model.persistence.IUserPersistance;
|
||||
import toDo.User;
|
||||
|
||||
/**
|
||||
* Dummyklasse zum Testen
|
||||
* @author Tim Tenbusch
|
||||
*
|
||||
*/
|
||||
public class UserDummy implements IUserPersistance {
|
||||
|
||||
public User readUser(String username) {
|
||||
return new User(1, "Dummy", "Persistenz", LocalDate.now(), "Dummystr.", "12C", "11111", "Nowhere", username, "pass", 12000, "gefangen", 1.58);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user