Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //import de la classe Scanner
- import java.util.Scanner;
- //import de la classe JOptionPane
- import javax.swing.JOptionPane;
- /**
- * Programme principal avec la méthode main
- * @author Département TIC - ESIGELEC
- * @version 2.1
- */
- public class SimulateurAppX {
- public static void main(String[] args) {
- // création de l'environnement et récupération du terrain
- int n = 5;
- Terrain t = Environnement.creerEnvironnement(n, n);
- // creation du robot
- Robot robot = new Robot(0, 0, "sud");
- // ajout du robot sur le terrain
- t.ajouterRobot(robot);
- t.ajouterPlusieursVictimes();
- // met à jour les composants graphiques
- t.updateIHM();
- //ajouter ici le code de déplacement du robot
- int pas = 0;
- int colonne = 1;
- //recherche de victimes
- while(colonne<=n) {
- while(true) {
- if (robot.isObstacleDevant() && (colonne%2 == 1)) {
- robot.tournerGauche();
- } else if (!robot.isObstacleDevant() && (colonne%2 == 1)) {
- robot.tournerGauche();
- colonne++;
- } else if (robot.isObstacleDevant() && (colonne%2 == 0)) {
- robot.tournerDroite();
- } else if (!robot.isObstacleDevant() && (colonne%2 == 0)) {
- robot.tournerDroite();
- colonne++;
- }
- pas++;
- robot.avancer();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement