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

PickUpThings with Becker Robot Java

Description:

In this example I will be showing you how to pick things with Becker Robot

Code:

import becker.robots.*;
import java.util.Random;

public class PickUpThings {
   public static void main(String[] arg) {
	    //problem setup
	    City oakville = new City(10,10);
	    Robot roby = new Robot(oakville, 1, 1, Direction.EAST);      
	    Random generator = new Random();
	    int avenue = generator.nextInt(7) + 4;
       
       	for (int i = 2; i<avenue; i++){
       	    Thing t = new Thing(oakville, 1, i);
       	}
    	System.out.print("The number of things = " + sweepStreet(roby));
	}
      //call the method to display the number of things
    private static int sweepStreet(Robot roby) {
	   int things = 0;
	   roby.move();
	   while (roby.canPickThing()){
		   roby.pickThing();
		   roby.move();
		   things++;
	   }
   return things;
	}  
}
   

   
Attachments: None

Tags: Pick Becker Thing Things

Total Views: 3118

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 11/11/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.