NEWS: Total Picture Views: 155282 | Total Article Views: 165616 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. PickUpThings with Becker Robot | 3. How to read a JSON and work with it | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

Becker Sorting Things Java

Description:

In this example I will be sorting/picking and putting things.

Code:

/**
 * Program Hunter.java
 */

import becker.robots.*;

public class Hunter {
   
	   public static void main(String[] arg) {
	      
	      City newYork = new City();
	      RobotSE guy = new RobotSE(newYork, 1, 1, Direction.EAST);
	      
	      makeMyWalls(newYork);
	      makeMyThings(newYork);
	      
	      Thing[] things = new Thing[5];
	      for (int i=0; i<5;i++) {
	      	things[i]= new Thing(newYork,i+2,i+1);
	      	things[i].getIcon().setLabel("T" + i);
	      }
	      
	      PickThings(guy);
	      DropThings(guy,things);
	      
	   }
	   public static void PickThings (RobotSE guy) {
		    for (int i=0;i<5;i++) {
		      guy.turnRight();
		      guy.move();
		      guy.turnLeft();
		      guy.pickThing();
		      guy.move();
		    } 
		   
		}
		
		public static void DropThings (RobotSE r, Thing[] t) {
			r.turnAround();
				for (int i=0; i<5;i++) {
			   		r.move();
			   		r.putThing(t[i]);
			   		r.turnRight();
			   		r.move();
			   		r.turnLeft();
			   	}
		}
	
	   
	   //method for creating things
	   public static void makeMyThings(City city){
	      //Thing t1 = new Thing(city, 5,1);
	      //Thing t2 = new Thing(city, 4,2);
	      //Thing t3 = new Thing(city, 3,3);
	      //Thing t4 = new Thing(city, 2,4);
	      //Thing t5 = new Thing(city, 1,5);
	    
	 
	    }
	   
	   
	   //method for creating walls
	  private static void makeMyWalls(City city) {
	      
	      Wall[] walls = new Wall[24];
	      // east walls
	      for (int x=0; x<24 ;x++) {
		      for (int a=1; a<7 ;a++) {
		      	walls[x] = new Wall(city, a, 6, Direction.EAST);
		      }
		    
		      //north walls 
		      for (int b=1; b<7 ;b++) {
		      	walls[x] = new Wall(city, 1, b, Direction.NORTH);
		      }
		      
		      //west walls
		      for (int c=1; c<7 ;c++) {
		      	walls[x] = new Wall(city, c, 1, Direction.WEST);
		      }  
		            
		      //south walls
		       for (int d=1; d<7 ;d++) {
		      	walls[x] = new Wall(city, 6, d, Direction.SOUTH);
		      }
	      }
	   }
}
Attachments:

Tags: Netbeans Becker Robot Becker Robot Sorting Things Sorting

Total Views: 2018

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 12/05/14 and updated on 12/14/14


affiliate_link

Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.