From 88493290fd5ea30be96f478053bd551ba07a90f9 Mon Sep 17 00:00:00 2001 From: Daniel Zdravkovic <3012893@stud.hs-mannheim.de> Date: Mon, 10 Jun 2024 14:40:53 +0200 Subject: [PATCH] sign_in_user method implemented --- pom.xml | 25 +++++++++++++++++++ .../java/de/hs_mannheim/domain/System.java | 14 +++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1a81f1b..e1f5961 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,31 @@ json 20210307 + + commons-codec + commons-codec + 1.17.0 + + + org.apache.poi + poi + 3.9 + + + org.apache.poi + poi-ooxml + 5.2.3 + + + commons-io + commons-io + 2.7 + + + org.apache.logging.log4j + log4j-core + 2.20.0 + diff --git a/src/main/java/de/hs_mannheim/domain/System.java b/src/main/java/de/hs_mannheim/domain/System.java index c5513e7..e9613a6 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -94,8 +94,18 @@ public class System { return all_users; } - public boolean sign_in_user(String username, String password){ - return true; + public boolean sign_in_user(String username, String password) throws IOException { + ArrayList mem = new ArrayList<>(get_all_user()); + + for(User user : mem){ + if(user.getUsername().equals(username) && user.getPassword().equals(password)){ + current_user = new User(user.getUsername(), user.getPassword(), + user.getHometown(), user.getZip(), user.getCar_name(), + user.getCar_l_100km(), user.getCar_avg_kmh(), user.getBike_avg_kmh()); + return true; + } + } + return false; } public boolean sign_up_user(String username, String password, String hometown, int zip,