diff --git a/src/main/java/de/hs_mannheim/domain/System.java b/src/main/java/de/hs_mannheim/domain/System.java index 36ed716..e99da42 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -103,10 +103,22 @@ public class System { public boolean sign_up_user(String username, String password, String hometown, String zipS, String car_name, String car_l_100kmS, String car_avg_kmhS, String bike_avg_kmhS){ - int zip = Integer.parseInt(zipS); - double car_l_100km = Double.parseDouble(car_l_100kmS); - double car_avg_kmh = Double.parseDouble(car_avg_kmhS); - double bike_avg_kmh = Double.parseDouble(bike_avg_kmhS); + int zip; + double car_l_100km; + double car_avg_kmh; + double bike_avg_kmh; + + try{ + zip = Integer.parseInt(zipS); + car_l_100km = Double.parseDouble(car_l_100kmS); + car_avg_kmh = Double.parseDouble(car_avg_kmhS); + bike_avg_kmh = Double.parseDouble(bike_avg_kmhS); + } catch (NumberFormatException n){ + return false; + } + + if(username.equals("")||password.equals("")||hometown.equals("")||zipS.equals("")) + return false; for(User user: this.all_user) if(user.getUsername().equals(username)) diff --git a/src/main/java/de/hs_mannheim/domain/User.java b/src/main/java/de/hs_mannheim/domain/User.java index a1d202e..b1f311b 100644 --- a/src/main/java/de/hs_mannheim/domain/User.java +++ b/src/main/java/de/hs_mannheim/domain/User.java @@ -5,11 +5,11 @@ public class User { private String username = ""; private String password = ""; private String hometown = ""; - private int zip; + private int zip = 0; private String car_name = ""; - private double car_l_100km; - private double car_avg_kmh; - private double bike_avg_kmh; + private double car_l_100km = 0; + private double car_avg_kmh = 0; + private double bike_avg_kmh = 0; public User(){}