From 18ee85061eb6902414ec2c4e610ecf9e7f0855f5 Mon Sep 17 00:00:00 2001 From: Simoes Lukas Date: Fri, 21 Nov 2025 14:41:22 +0100 Subject: [PATCH] tp --- DEV3.2/TP08/01_Tri/Tri.class | Bin 0 -> 1752 bytes DEV3.2/TP08/01_Tri/Tri.java | 67 +++++++++++++++++ .../Authentification.class | Bin 0 -> 2705 bytes .../02_Authentification/Authentification.java | 70 ++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 DEV3.2/TP08/01_Tri/Tri.class create mode 100644 DEV3.2/TP08/01_Tri/Tri.java create mode 100644 DEV3.2/TP08/02_Authentification/Authentification.class create mode 100644 DEV3.2/TP08/02_Authentification/Authentification.java diff --git a/DEV3.2/TP08/01_Tri/Tri.class b/DEV3.2/TP08/01_Tri/Tri.class new file mode 100644 index 0000000000000000000000000000000000000000..c69f583e962586e4c2f0779dbaa6fa0f006b19e4 GIT binary patch literal 1752 zcmX^0Z`VEs1_pD62rdQz26avbRt60ap$Q_i*cr6B7+4w9L4*!SM3;j>55&KGO(u>mxN`eq%txvMlmw5*<|Krme?^eFl%UrF*2|?=YwSU zeKPY>{YrC_Qj0HWr_MZiFxVz5K(J(23tl3mfXb5JVpjFjc7~-nqlk=c8m;M!TF^{$*FFc zAX_;?iZb;;M)5F6Fi7$+h%t!sFbFaT@h}K8h%hoRhZJSWCkpjZS6R%=j{2Y@0Ygpol7tRI|WGV{vvvs0l72NHsAiOD7TMV0IfVT=rH zKKc3Cr3H)(Jf3-ZsYT8?iN(dK#f%Iyki7ym0}}rpiFqkGsl_S~jn)t!fUSZ=Cb9^M z#*oT_RAfo0a^#qYc?HQ(s1eSIIXS_ZC8^fz4B?Cnsu=#m<~BwKIsEDv6d70<1Q-|? zSQwZ2Id)a7!+wu93T;pB*+m=U>_JU@Gvkih%m4- zh%$hR2|)&N1|bG125AOq1|h9Cx21~~=>26hHkAt^3F zb_PaJ$pLk7B?B`969WT-l@O;7$Q{QR1hql*HU_R;4BQM1J|G_RE|8TVc@C&N2SR=W zI2u4fE62djz`&rvz|5eR;4TCC!HG?*TJ%bU01K4hH2B!ZE0t~F|3@Yqkl97>t r;Rk~h12cmv*b{0D!QiyP$Pma7$`HgL$zTAEZYBmp21W)WFlhn+u(Epn literal 0 HcmV?d00001 diff --git a/DEV3.2/TP08/01_Tri/Tri.java b/DEV3.2/TP08/01_Tri/Tri.java new file mode 100644 index 0000000..1d26d98 --- /dev/null +++ b/DEV3.2/TP08/01_Tri/Tri.java @@ -0,0 +1,67 @@ +import java.awt.*; + +public class Tri { + + private double valeur; + private Tri filsGauche; + private Tri filsDroit; + private boolean estVide; + + public Tri() { + this.estVide = true; + } + + public Tri(double valeur) { + this.estVide = false; + this.valeur = valeur; + } + + public void ajouter(double valeur) { + if (this.estVide) { + this.valeur = valeur; + this.estVide = false; + return; + } + + if (valeur < this.valeur) { + if (this.filsGauche == null) { + this.filsGauche = new Tri(); + } + filsGauche.ajouter(valeur); + } else { + if (this.filsDroit == null) { + this.filsDroit = new Tri(); + } + filsDroit.ajouter(valeur); + } + } + + public String toString() { + String aRenvoyer = ""; + + if (this.filsGauche != null) { + aRenvoyer += this.filsGauche.toString(); + } + + aRenvoyer += this.valeur + " "; + + if (this.filsDroit != null) { + aRenvoyer += this.filsDroit.toString(); + } + + return aRenvoyer; + } + + + public static void main(String[] args) { + Tri racine = new Tri(); + + for (String chaine : args) { + racine.ajouter(Double.parseDouble(chaine)); + } + + System.out.println(racine); + } + + +} \ No newline at end of file diff --git a/DEV3.2/TP08/02_Authentification/Authentification.class b/DEV3.2/TP08/02_Authentification/Authentification.class new file mode 100644 index 0000000000000000000000000000000000000000..233968ed9b38ab1083101b2f4f5b5a4390b8a032 GIT binary patch literal 2705 zcmX^0Z`VEs1_pD6$y^K?47ThHc3cch47QvM{0#Qo3=RyAoD5D3&O!_f4DMVE9t@r! zF)twoMh15d1|J~?CI)wqh@TJxGlM%jLjV^8Kgf_kc7`C3#$YZ6A%+kx20?~U4u&ue zhHx$h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HS4eytgTyR`ES+r(l0s73 z7^JOOBw3h^{6N7VvyDMkS4eIfgTzb*A#F((79&X(R-bEf{FK6HenWX{>(*Ki}Gw}FrVo(!O-^RePk%5sxilLWb0)r|8Bx3y-gc%qZ zv=}%TbQq)<^ciFs3>nlIj2H|Vj2X-rOd0GL%oyAm%o)NMEEwV$EE)0`tQg7}tQndZ zY#F*3>=}9)oEauCI5JFRaAKIr-~tXAMFx(446^JD{Ok;Z> dictionnaire; + + public Authentification() { + this.dictionnaire = new HashMap<>(); + } + + public void ajouter(String username, String password) { + if (this.dictionnaire.get(username) != null) { + System.out.println("L'utilisateur '" + username + "' existe déjà."); + } else { + this.dictionnaire.put(username, password); + } + } + + public void authentifier(String username, String password) { + if (this.dictionnaire.get(username) == null) { + System.out.println("L'utilisateur '" + username + "' n'existe pas."); + } else if (this.dictionnaire.get(username) != password) { + System.out.println("Le mot de passe est incorrect."); + } else { + System.out.println("L'utilisateur '" + username + "' est authentifié."); + } + } + + public void supprimer(String username) { + if (this.dictionnaire.get(username) == null) { + System.out.println("L'utilisateur '" + username + "' n'existe pas."); + } else { + this.dictionnaire.remove(username); + System.out.println("L'utilisateur '" + username + "' a été supprimé"); + } + } + + public static void main(String[] args) { + Authentification auth = new Authentification(); + + BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); + + try { + String input = ""; + + while (!input.equals("quit")) { + String[] ligne = console.readLine().split(" "); + input = ligne[0]; + + System.out.print("> "); + if (input.equals("add")) { + auth.ajouter(ligne[1], ligne[2]); + } else if (input.equals("auth")) { + auth.authentifier(ligne[1], ligne[2]); + } else if (input.equals("del")) { + auth.supprimer(ligne[1]); + } else { + System.out.println("Commande non reconnue."); + } + } + + } catch (IOException e) { + System.err.println("Erreur de la console"); + } + } + +} \ No newline at end of file