Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. //import de la classe Scanner
  2. import java.util.Scanner;
  3. //import de la classe JOptionPane
  4. import javax.swing.JOptionPane;
  5.  
  6. /**
  7. * Programme principal avec la méthode main
  8. * @author Département TIC - ESIGELEC
  9. * @version 2.1
  10. */
  11. public class SimulateurAppX {
  12.  
  13. public static void main(String[] args) {
  14. // création de l'environnement et récupération du terrain
  15. int n = 5;
  16. Terrain t = Environnement.creerEnvironnement(n, n);
  17.  
  18. // creation du robot
  19. Robot robot = new Robot(0, 0, "sud");
  20.  
  21. // ajout du robot sur le terrain
  22. t.ajouterRobot(robot);
  23. t.ajouterPlusieursVictimes();
  24.  
  25. // met à jour les composants graphiques
  26. t.updateIHM();
  27.  
  28.  
  29. //ajouter ici le code de déplacement du robot
  30.  
  31. int pas = 0;
  32. int colonne = 1;
  33.  
  34. //recherche de victimes
  35. while(colonne<=n) {
  36.  
  37. while(true) {
  38.  
  39. if (robot.isObstacleDevant() && (colonne%2 == 1)) {
  40.  
  41. robot.tournerGauche();
  42.  
  43. } else if (!robot.isObstacleDevant() && (colonne%2 == 1)) {
  44.  
  45. robot.tournerGauche();
  46. colonne++;
  47.  
  48. } else if (robot.isObstacleDevant() && (colonne%2 == 0)) {
  49.  
  50. robot.tournerDroite();
  51.  
  52. } else if (!robot.isObstacleDevant() && (colonne%2 == 0)) {
  53.  
  54. robot.tournerDroite();
  55. colonne++;
  56.  
  57. }
  58.  
  59. pas++;
  60. robot.avancer();
  61.  
  62. }
  63.  
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement