ANDROID WE
This commit is contained in:
@@ -1,42 +1,43 @@
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
|
||||
public class Authentification {
|
||||
|
||||
private Map<String, String> dictionnaire;
|
||||
private ABR dictionnaire;
|
||||
|
||||
public Authentification() {
|
||||
this.dictionnaire = new HashMap<>();
|
||||
this.dictionnaire = new ABR();
|
||||
}
|
||||
|
||||
public void ajouter(String username, String password) {
|
||||
if (this.dictionnaire.get(username) != null) {
|
||||
if (this.dictionnaire.estPresent(username)) {
|
||||
System.out.println("L'utilisateur '" + username + "' existe déjà.");
|
||||
} else {
|
||||
this.dictionnaire.put(username, password);
|
||||
this.dictionnaire.ajouterUtilisateur(username, password);
|
||||
System.out.println("Utilisateur ajouté.");
|
||||
}
|
||||
System.out.println(this.dictionnaire);
|
||||
}
|
||||
|
||||
public void authentifier(String username, String password) {
|
||||
if (this.dictionnaire.get(username) == null) {
|
||||
if (!this.dictionnaire.estPresent(username)) {
|
||||
System.out.println("L'utilisateur '" + username + "' n'existe pas.");
|
||||
} else if (!this.dictionnaire.get(username).equals(password)) {
|
||||
} else if (!this.dictionnaire.authentifier(username, password)) {
|
||||
System.out.println("Le mot de passe est incorrect.");
|
||||
} else {
|
||||
System.out.println("L'utilisateur '" + username + "' est authentifié.");
|
||||
}
|
||||
System.out.println(this.dictionnaire);
|
||||
}
|
||||
|
||||
public void supprimer(String username) {
|
||||
if (this.dictionnaire.get(username) == null) {
|
||||
if (!this.dictionnaire.estPresent(username)) {
|
||||
System.out.println("L'utilisateur '" + username + "' n'existe pas.");
|
||||
} else {
|
||||
this.dictionnaire.remove(username);
|
||||
this.dictionnaire.supprimer(username);
|
||||
System.out.println("L'utilisateur '" + username + "' a été supprimé");
|
||||
}
|
||||
System.out.println(this.dictionnaire);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -63,7 +64,7 @@ public class Authentification {
|
||||
auth.authentifier(ligne[1], ligne[2]);
|
||||
} else if (input.equals("del")) {
|
||||
auth.supprimer(ligne[1]);
|
||||
} else if (input.equals("quit")) {
|
||||
} else. if (input.equals("quit")) {
|
||||
|
||||
} else {
|
||||
System.out.println("Commande non reconnue.");
|
||||
|
||||
Reference in New Issue
Block a user