sign_in_user method implemented

sign_in_up_out
Daniel Zdravkovic 2024-06-10 14:40:53 +02:00
parent 359a88b773
commit 88493290fd
2 changed files with 37 additions and 2 deletions

25
pom.xml
View File

@ -28,6 +28,31 @@
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20210307</version> <version>20210307</version>
</dependency> </dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.17.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.20.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<resources> <resources>

View File

@ -94,9 +94,19 @@ public class System {
return all_users; return all_users;
} }
public boolean sign_in_user(String username, String password){ public boolean sign_in_user(String username, String password) throws IOException {
ArrayList<User> 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 true;
} }
}
return false;
}
public boolean sign_up_user(String username, String password, String hometown, int zip, public boolean sign_up_user(String username, String password, String hometown, int zip,
String car_name, double car_co2_km, double car_avg_kmh, double bike_avg_kmh){ String car_name, double car_co2_km, double car_avg_kmh, double bike_avg_kmh){