Compare commits
2 Commits
50e0d7fa5f
...
b08e96be47
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b08e96be47 | ||
|
|
b2ebfe848e |
3
DEV1.1/TP12/.dockerignore
Normal file
3
DEV1.1/TP12/.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
*.o
|
||||
app
|
||||
.git
|
||||
12
DEV1.1/TP12/Dockerfile
Normal file
12
DEV1.1/TP12/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM gcc:13 AS build
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN gcc -ansi -pedantic tests.c -o app
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/app .
|
||||
CMD ["./app"]
|
||||
|
||||
# sudo docker build -t app-c
|
||||
# sudo docker run app-c
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
int main(void){
|
||||
int tab[TAILLE_TABLEAU];
|
||||
int tab_inverse[TAILLE_TABLEAU];
|
||||
int i;
|
||||
srand(time(NULL));
|
||||
|
||||
@@ -34,33 +33,6 @@ int main(void){
|
||||
printf("+-----");
|
||||
}
|
||||
printf("+\n");
|
||||
|
||||
/* Remplissage du tableau inverse */
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
tab_inverse[i] = tab[TAILLE_TABLEAU-i-1];
|
||||
}
|
||||
|
||||
/* Affichage du tableau */
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
printf("+-----");
|
||||
}
|
||||
printf("+\n");
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
if (tab_inverse[i] < 10 && tab_inverse[i] >= 0) {
|
||||
printf("| %d ", tab_inverse[i]);
|
||||
}
|
||||
else if (tab_inverse[i] < -9) {
|
||||
printf("| %d ", tab_inverse[i]);
|
||||
}
|
||||
else {
|
||||
printf("| %d ", tab_inverse[i]);
|
||||
}
|
||||
}
|
||||
printf("|\n");
|
||||
for (i = 0; i != TAILLE_TABLEAU; i++) {
|
||||
printf("+-----");
|
||||
}
|
||||
printf("+\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
BIN
DEV3.2/CM1/01_Division/Main.class
Normal file
BIN
DEV3.2/CM1/01_Division/Main.class
Normal file
Binary file not shown.
31
DEV3.2/CM1/01_Division/Main.java
Normal file
31
DEV3.2/CM1/01_Division/Main.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
ArrayDeque<String> textes = new ArrayDeque<>();
|
||||
ArrayDeque<Integer> entiers = new ArrayDeque<>();
|
||||
|
||||
for (String chaine : args) {
|
||||
try {
|
||||
Integer entier = new Integer(Integer.parseInt(chaine));
|
||||
|
||||
entiers.addLast(entier.intValue());
|
||||
} catch (NumberFormatException e) {
|
||||
textes.addLast(chaine);
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer entier : entiers) {
|
||||
System.out.print(entier + " ");
|
||||
}
|
||||
|
||||
System.out.println("");
|
||||
|
||||
for (String texte : textes) {
|
||||
System.out.print(texte + " ");
|
||||
}
|
||||
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
Binary file not shown.
BIN
DEV3.2/TP08/02_Authentification/ABR.class
Normal file
BIN
DEV3.2/TP08/02_Authentification/ABR.class
Normal file
Binary file not shown.
112
DEV3.2/TP08/02_Authentification/ABR.java
Normal file
112
DEV3.2/TP08/02_Authentification/ABR.java
Normal file
@@ -0,0 +1,112 @@
|
||||
public class ABR {
|
||||
|
||||
private String valeur;
|
||||
private ABR filsGauche;
|
||||
private ABR filsDroit;
|
||||
private int compteur = 0;
|
||||
|
||||
public ABR() {
|
||||
this.valeur = null;
|
||||
this.filsDroit = null;
|
||||
this.filsGauche = null;
|
||||
}
|
||||
|
||||
public ABR(String valeur) {
|
||||
this.valeur = valeur;
|
||||
}
|
||||
|
||||
|
||||
public boolean authentifier(String id, String password) {
|
||||
|
||||
// Si le noeud courant est vide, aller dans le fils gauche
|
||||
if (this.valeur == null) {
|
||||
if (this.filsGauche != null) {
|
||||
return this.filsGauche.authentifier(id, password);
|
||||
}
|
||||
return false; // rien dans l'arbre
|
||||
}
|
||||
|
||||
// Si on trouve l'id au noeud courant
|
||||
if (this.valeur.equals(id)) {
|
||||
if (this.filsDroit != null && this.filsDroit.valeur.equals(password)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sinon, continuer à gauche
|
||||
if (this.filsGauche != null) {
|
||||
return this.filsGauche.authentifier(id, password);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void supprimer(String id) {
|
||||
if (this.filsGauche != null) {
|
||||
if (this.filsGauche.valeur.equals(id)) {
|
||||
if (this.filsGauche.filsGauche != null) {
|
||||
this.filsGauche = this.filsGauche.filsGauche;
|
||||
} else {
|
||||
this.filsGauche = null;
|
||||
}
|
||||
System.out.println("Suppression effectuée.");
|
||||
} else {
|
||||
this.filsGauche.supprimer(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ajouterUtilisateur(String id, String password) {
|
||||
if (this.filsGauche != null && this.filsGauche.equals(id)) {
|
||||
System.out.println("Valeur déjà présente.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.filsGauche != null) {
|
||||
this.filsGauche.ajouterUtilisateur(id, password);
|
||||
} else {
|
||||
this.filsGauche = new ABR(id);
|
||||
this.filsGauche.filsDroit = new ABR(password);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean estPresent(String id) {
|
||||
if (this.filsGauche == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.compteur == 0) {
|
||||
this.compteur++;
|
||||
this.filsGauche.estPresent(id);
|
||||
}
|
||||
|
||||
if (this.compteur != 0 && this.valeur == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.valeur.equals(id)) {
|
||||
return true;
|
||||
} else {
|
||||
return this.filsGauche.estPresent(id);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String aRenvoyer = "";
|
||||
|
||||
if (this.filsDroit == null && this.filsGauche == null) {
|
||||
return "";
|
||||
} else {
|
||||
if (this.filsGauche == null) {
|
||||
return "";
|
||||
} else {
|
||||
aRenvoyer += "Identifiant : " + this.filsGauche.valeur + " / Mot de passe : " + this.filsGauche.filsDroit.valeur + "\n";
|
||||
return aRenvoyer + this.filsGauche.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -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.");
|
||||
|
||||
47
DEV4.5/TP01_Mise_en_page/01_Chat/v1/activity_main.xml
Normal file
47
DEV4.5/TP01_Mise_en_page/01_Chat/v1/activity_main.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#555"
|
||||
android:padding="10dp"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="660dp"
|
||||
android:layout_gravity="top"
|
||||
android:background="@color/white"
|
||||
android:inputType="textMultiLine"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OK"
|
||||
android:textSize="20dp"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
42
DEV4.5/TP01_Mise_en_page/01_Chat/v2/activity_main.xml
Normal file
42
DEV4.5/TP01_Mise_en_page/01_Chat/v2/activity_main.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#555"
|
||||
android:padding="10dp"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/champPrincipal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="@color/white"
|
||||
android:inputType="textMultiLine" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/champSecondaire"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="bottom"
|
||||
android:layout_toStartOf="@+id/bouton"
|
||||
android:layout_below="@+id/champPrincipal"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bouton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_below="@+id/champPrincipal"
|
||||
android:text="OK"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
43
Docker/Infos.txt
Normal file
43
Docker/Infos.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
---------------------------------------------
|
||||
Dockerfile Java
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
FROM eclipse-temurin:17-jdk
|
||||
|
||||
WORKDIR /Ecriture
|
||||
COPY Ecriture.java .
|
||||
|
||||
RUN javac Ecriture.java
|
||||
|
||||
CMD ["java", "Ecriture"]
|
||||
|
||||
|
||||
---------------------------------------------
|
||||
Commandes
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
Build & run :
|
||||
--------------
|
||||
|
||||
sudo docker build -t appli .
|
||||
sudo docker run --r appli
|
||||
|
||||
Statut docker :
|
||||
----------------
|
||||
|
||||
sudo docker ps (--> Liste l'ensemble des processus dockers en cours, équivalent de ls pour les dockers lancés)
|
||||
|
||||
Accéder aux fichiers du conteneur :
|
||||
-----------------------
|
||||
|
||||
sudo docker exec -it <id_du_conteneur> bash (--> Permet d'accéder aux fichiers du conteneur, on obtient l'id du conteneur avec sudo docker ps)
|
||||
|
||||
|
||||
Créer un volume (monter un dossier de sa machine dans le docker) :
|
||||
------------------------------------------------------------------
|
||||
|
||||
sudo docker run -v $(pwd):/appli nom-image (--> le dossier ":/appli" doit être le nom spécifié dans le Dockerfile, soit WORKDIR /appli)
|
||||
|
||||
|
||||
8
Docker/TP2/Dockerfile
Normal file
8
Docker/TP2/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM eclipse-temurin:17-jdk
|
||||
|
||||
WORKDIR /Ecriture
|
||||
COPY Ecriture.java .
|
||||
|
||||
RUN javac Ecriture.java
|
||||
|
||||
CMD ["java", "Ecriture"]
|
||||
BIN
Docker/TP2/Ecriture.class
Normal file
BIN
Docker/TP2/Ecriture.class
Normal file
Binary file not shown.
48
Docker/TP2/Ecriture.java
Normal file
48
Docker/TP2/Ecriture.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Ecriture {
|
||||
|
||||
|
||||
public static void ecrireFichier() {
|
||||
try {
|
||||
|
||||
BufferedWriter flux = new BufferedWriter(new FileWriter("Texte.txt", true));
|
||||
|
||||
try {
|
||||
|
||||
String aEcrire = "Hello world!";
|
||||
flux.write(aEcrire, 0, aEcrire.length());
|
||||
flux.newLine();
|
||||
|
||||
try {
|
||||
|
||||
flux.close();
|
||||
|
||||
} catch (IOException e3) {
|
||||
System.err.println("Erreur de fermeture.");
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur d'écriture.");
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
System.err.println("Erreur d'ouverture.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
while (true) {
|
||||
Ecriture.ecrireFichier();
|
||||
System.out.println("Fichier modifié.");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e4) {
|
||||
System.err.println("Erreur de timer.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2
Docker/TP2/Texte.txt
Normal file
2
Docker/TP2/Texte.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Hello world!
|
||||
Hello world!
|
||||
Reference in New Issue
Block a user