Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -29,7 +29,6 @@ public class Sautoir extends JComponent {
|
|||||||
fenetre.setSize(250, 250);
|
fenetre.setSize(250, 250);
|
||||||
fenetre.setLocation(0, 0);
|
fenetre.setLocation(0, 0);
|
||||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
fenetre.setAlwaysOnTop(true);
|
|
||||||
fenetre.setLayout(layout);
|
fenetre.setLayout(layout);
|
||||||
for (int i = 0; i != 25; i++) {
|
for (int i = 0; i != 25; i++) {
|
||||||
fenetre.add(new Sautoir());
|
fenetre.add(new Sautoir());
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,6 @@ public class Fenetre extends JFrame {
|
|||||||
this.setSize(500, 600);
|
this.setSize(500, 600);
|
||||||
this.setLocation(100, 100);
|
this.setLocation(100, 100);
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
this.setAlwaysOnTop(true);
|
|
||||||
this.setLayout(new GridLayout(1, 1));
|
this.setLayout(new GridLayout(1, 1));
|
||||||
LectureFichier lecture = new LectureFichier();
|
LectureFichier lecture = new LectureFichier();
|
||||||
EcritureFichier ecriture = new EcritureFichier("test", lecture.getCoordY(), lecture.getNbPoints());
|
EcritureFichier ecriture = new EcritureFichier("test", lecture.getCoordY(), lecture.getNbPoints());
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,17 +9,17 @@ public class Connexion {
|
|||||||
|
|
||||||
public Connexion() {
|
public Connexion() {
|
||||||
try {
|
try {
|
||||||
|
Connection cnx = DriverManager.getConnection(
|
||||||
|
"jdbc:mariadb://dwarves.iut-fbleau.fr/simoes",
|
||||||
|
"simoes", "simoes"
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("org.mariadb.jdbc.Driver");
|
Class.forName("org.mariadb.jdbc.Driver");
|
||||||
} catch (ClassNotFoundException e2) {
|
} catch (ClassNotFoundException e2) {
|
||||||
System.err.println("Problème de pilote.");
|
System.err.println("Problème de pilote.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection cnx = DriverManager.getConnection(
|
|
||||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/simoes",
|
|
||||||
"simoes", "simoes"
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement pst = cnx.prepareStatement(
|
PreparedStatement pst = cnx.prepareStatement(
|
||||||
"SELECT SUM(points), competiteur FROM pays GROUP BY competiteur ASC;"
|
"SELECT SUM(points), competiteur FROM pays GROUP BY competiteur ASC;"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,16 +5,17 @@ import java.util.ArrayDeque;
|
|||||||
public class Fenetre extends JFrame {
|
public class Fenetre extends JFrame {
|
||||||
|
|
||||||
public Fenetre() {
|
public Fenetre() {
|
||||||
this.setSize(460, 483);
|
this.setSize(500, 500);
|
||||||
this.setLocation(100, 100);
|
this.setLocation(100, 100);
|
||||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
this.setLayout(new GridLayout(1, 1));
|
||||||
ArrayDeque<Point> coordSnake = new ArrayDeque<>();
|
ArrayDeque<Point> coordSnake = new ArrayDeque<>();
|
||||||
for (int i = 0; i != 5; i++) {
|
for (int i = 0; i != 5; i++) {
|
||||||
coordSnake.addLast(new Point(i+5, 5));
|
coordSnake.addLast(new Point(i+5, 5));
|
||||||
}
|
}
|
||||||
JGrilleDeJeu grille = new JGrilleDeJeu(this, coordSnake);
|
JGrilleDeJeu grille = new JGrilleDeJeu(this, coordSnake);
|
||||||
grille.setSize(new Dimension(500, 500));
|
|
||||||
this.add(grille);
|
this.add(grille);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
@@ -24,13 +24,14 @@ public class JGrilleDeJeu extends JComponent {
|
|||||||
this.controleur = new ControleurClavier();
|
this.controleur = new ControleurClavier();
|
||||||
this.fenetre.addKeyListener(controleur);
|
this.fenetre.addKeyListener(controleur);
|
||||||
this.directionActuelle = "Right";
|
this.directionActuelle = "Right";
|
||||||
this.intervalleTimer = 100;
|
this.intervalleTimer = 150;
|
||||||
|
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
int coordXPomme = Math.abs(r.nextInt() % TAILLE_GRILLE);
|
int coordXPomme = Math.abs(r.nextInt() % TAILLE_GRILLE);
|
||||||
int coordYPomme = Math.abs(r.nextInt() % TAILLE_GRILLE);
|
int coordYPomme = Math.abs(r.nextInt() % TAILLE_GRILLE);
|
||||||
|
|
||||||
this.posPomme = new Point(coordXPomme, coordYPomme);
|
this.posPomme = new Point(coordXPomme, coordYPomme);
|
||||||
|
|
||||||
this.grille[coordXPomme][coordYPomme] = 'r';
|
this.grille[coordXPomme][coordYPomme] = 'r';
|
||||||
|
|
||||||
this.timer = new Timer();
|
this.timer = new Timer();
|
||||||
@@ -46,8 +47,6 @@ public class JGrilleDeJeu extends JComponent {
|
|||||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
int tailleCase = this.getWidth()/TAILLE_GRILLE;
|
|
||||||
|
|
||||||
for (int i = 0; i != TAILLE_GRILLE; i++) {
|
for (int i = 0; i != TAILLE_GRILLE; i++) {
|
||||||
for (int j = 0; j != TAILLE_GRILLE; j++) {
|
for (int j = 0; j != TAILLE_GRILLE; j++) {
|
||||||
switch (grille[i][j]) {
|
switch (grille[i][j]) {
|
||||||
@@ -61,12 +60,11 @@ public class JGrilleDeJeu extends JComponent {
|
|||||||
secondPinceau.setColor(Color.ORANGE);
|
secondPinceau.setColor(Color.ORANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
secondPinceau.fillRect(
|
secondPinceau.fillRect(
|
||||||
tailleCase*i+1,
|
this.getWidth()/TAILLE_GRILLE*i+1,
|
||||||
tailleCase*j+1,
|
this.getHeight()/TAILLE_GRILLE*j+1,
|
||||||
tailleCase-2,
|
this.getWidth()/TAILLE_GRILLE-2,
|
||||||
tailleCase-2
|
this.getHeight()/TAILLE_GRILLE-2
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -74,29 +72,7 @@ public class JGrilleDeJeu extends JComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void avancerSnake() {
|
public void avancerSnake() {
|
||||||
|
this.coordSnake.removeFirst();
|
||||||
// ======== TON CODE REMPLACE ICI LA LOGIQUE DU DÉPLACEMENT ==========
|
|
||||||
boolean mangePomme = this.coordSnake.getLast().equals(this.posPomme);
|
|
||||||
if (!mangePomme) {
|
|
||||||
this.coordSnake.removeFirst(); // avance normale
|
|
||||||
}
|
|
||||||
|
|
||||||
Point tete = this.coordSnake.getLast();
|
|
||||||
switch (directionActuelle) {
|
|
||||||
case "Right": tete = new Point(tete.x + 1, tete.y); break;
|
|
||||||
case "Left": tete = new Point(tete.x - 1, tete.y); break;
|
|
||||||
case "Up": tete = new Point(tete.x, tete.y - 1); break;
|
|
||||||
case "Down": tete = new Point(tete.x, tete.y + 1); break;
|
|
||||||
}
|
|
||||||
this.coordSnake.addLast(tete);
|
|
||||||
|
|
||||||
if (mangePomme) {
|
|
||||||
Random r = new Random();
|
|
||||||
posPomme = new Point(r.nextInt(TAILLE_GRILLE), r.nextInt(TAILLE_GRILLE));
|
|
||||||
}
|
|
||||||
// ==================================================================
|
|
||||||
|
|
||||||
// Gestion de la direction selon les touches pressées
|
|
||||||
if (!this.controleur.getTouches().isEmpty()) {
|
if (!this.controleur.getTouches().isEmpty()) {
|
||||||
String toucheAModifier = this.controleur.getTouches().removeFirst();
|
String toucheAModifier = this.controleur.getTouches().removeFirst();
|
||||||
switch (this.directionActuelle) {
|
switch (this.directionActuelle) {
|
||||||
@@ -121,15 +97,56 @@ public class JGrilleDeJeu extends JComponent {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
switch (this.directionActuelle) {
|
||||||
|
case "Right":
|
||||||
|
this.coordSnake.addLast(new Point(this.coordSnake.getLast().x+1, this.coordSnake.getLast().y));
|
||||||
|
break;
|
||||||
|
case "Left":
|
||||||
|
this.coordSnake.addLast(new Point(this.coordSnake.getLast().x-1, this.coordSnake.getLast().y));
|
||||||
|
break;
|
||||||
|
case "Up":
|
||||||
|
this.coordSnake.addLast(new Point(this.coordSnake.getLast().x, this.coordSnake.getLast().y-1));
|
||||||
|
break;
|
||||||
|
case "Down":
|
||||||
|
this.coordSnake.addLast(new Point(this.coordSnake.getLast().x, this.coordSnake.getLast().y+1));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Efface la grille
|
|
||||||
for (int i = 0; i != TAILLE_GRILLE; i++) {
|
for (int i = 0; i != TAILLE_GRILLE; i++) {
|
||||||
for (int j = 0; j != TAILLE_GRILLE; j++) {
|
for (int j = 0; j != TAILLE_GRILLE; j++) {
|
||||||
this.grille[i][j] = 'g';
|
this.grille[i][j] = 'g';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.coordSnake.getLast().equals(this.posPomme)) {
|
||||||
|
Random r = new Random();
|
||||||
|
int coordXPomme = Math.abs(r.nextInt() % TAILLE_GRILLE);
|
||||||
|
int coordYPomme = Math.abs(r.nextInt() % TAILLE_GRILLE);
|
||||||
|
|
||||||
|
this.posPomme = new Point(coordXPomme, coordYPomme);
|
||||||
|
|
||||||
|
Point coordQueue = this.coordSnake.removeFirst();
|
||||||
|
Point coordAvantQueue = this.coordSnake.getFirst();
|
||||||
|
Point aAjouter;
|
||||||
|
|
||||||
|
if (coordAvantQueue.equals(new Point(coordQueue.x+1, coordQueue.y))) {
|
||||||
|
aAjouter = new Point(coordQueue.x-1, coordQueue.y);
|
||||||
|
}
|
||||||
|
else if (coordAvantQueue.equals(new Point(coordQueue.x-1, coordQueue.y))) {
|
||||||
|
aAjouter = new Point(coordQueue.x+1, coordQueue.y);
|
||||||
|
}
|
||||||
|
else if (coordAvantQueue.equals(new Point(coordQueue.x, coordQueue.y+1))) {
|
||||||
|
aAjouter = new Point(coordQueue.x, coordQueue.y-1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aAjouter = new Point(coordQueue.x, coordQueue.y+1);
|
||||||
|
}
|
||||||
|
this.coordSnake.addFirst(aAjouter);
|
||||||
|
this.coordSnake.addFirst(coordQueue);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int compteur = this.coordSnake.size();
|
int compteur = this.coordSnake.size();
|
||||||
for (Point point : this.coordSnake) {
|
for (Point point : this.coordSnake) {
|
||||||
@@ -144,6 +161,7 @@ public class JGrilleDeJeu extends JComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.grille[posPomme.x][posPomme.y] = 'r';
|
this.grille[posPomme.x][posPomme.y] = 'r';
|
||||||
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
TD_TP1.pdf
BIN
TD_TP1.pdf
Binary file not shown.
@@ -1,17 +0,0 @@
|
|||||||
TD/TP 2 : Duel d'Interfaces (CLI vs. GUI)
|
|
||||||
|
|
||||||
Chronomètre explorateur de fichiers (GUI) : 1m 19s
|
|
||||||
Chronomètre terminal (CLI) : 16s (avec rename)
|
|
||||||
|
|
||||||
Lorsque l'utilisateur est suffisament expérimenté, il sera toujours plus rapide et efficace avec la CLI qu'avec
|
|
||||||
la GUI. Pour un utilisateur lambda, il reste plus rapide de renommer chaque fichier individuellement plutôt que
|
|
||||||
de prendre le temps d'essayer de comprendre une commande. Si on cherche à être optimal, la CLI reste imbattable car on
|
|
||||||
peut réaliser l'entièreté de l'opération avec une seule commande, tandis que la GUI nécessite d'alterner plusieurs fois
|
|
||||||
entre souris et clavier pour renommer chaque fichier un par un. Cette solution reste abordable dans le cas présent (avec
|
|
||||||
15 fichiers), mais elle deviendrait ingérable avec une quantité de données conséquente (avec 1000 fichiers par exemple),
|
|
||||||
où l'utilisation du terminal deviendrait presque indispensable.
|
|
||||||
|
|
||||||
Commandes utilisées :
|
|
||||||
|
|
||||||
rename .jpg .png *.jpg
|
|
||||||
rename .txt .md *.txt
|
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user