1 / 7

Lab2

Lab2. Move around and checking conditions. Create a city and a robot. City Riyadh = new City(); RobotSE halo = new RobotSE (Riyadh, 0,0,Direction.EAST);. Make the robot move around in specific coordination. while( halo.getStreet ()<5){

dana-tran
Download Presentation

Lab2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab2 Move around and checking conditions

  2. Create a city and a robot City Riyadh = new City(); RobotSE halo = new RobotSE(Riyadh, 0,0,Direction.EAST);

  3. Make the robot move around in specific coordination. while(halo.getStreet()<5){ while(halo.getAvenue()<5 && halo.getAvenue()>0){ halo.move(); if (halo.getAvenue()==1) halo.turnLeft(); } halo.turnRight(); halo.move(); }

  4. Create a wall and let the robot stops when it sense it. Wall wa = new Wall(Riyadh,0,5,Direction.WEST); while(halo.frontIsClear()){ halo.move(); }

  5. Let the robot move then stops in a certain street while(halo.frontIsClear() && halo.getStreet()<5){ halo.move(); }

  6. Create a thing then pick it up Thing th1 = new Thing(Riyadh,5,0); while(halo.frontIsClear()){ halo.move(); if(halo.canPickThing()) { halo.pickThing(); break; } }

  7. Create a lamp and turn it off when the robot reach it Lamp la = new Lamp(Riyadh,0,0); while(halo.getStreet()>0){ halo.move(); if (halo.canPickThing()){ la.turnOff(); } }

More Related