12/30/10

Karel -the Robot learns Java using Eclipse Tutorial

Karel The Robot is a robot simulator that affords a gentle introduction to computer programming. Users write Karel programs and feed them to the simulator to watch them execute.

By solving karel problems you will build your logic and enjoy programming.



<-Karel 




Karel- its a robot.. its has its own world that is known as the grid. The grid has avenues (column) and streets(rows). Karel is placed at the 1st street and 1st avenues ie 1,1 if denotes in Cartesian co-ordinates.  


 This is Karels World.




Karel has only four Main functions :

1. move()- that makes karel move one step ahead.
2. putBeeper()- It puts a beeper.
3.pickBeeper()- it picks a beeper.
4. turnLeft()-makes karel turn left at that place itself.

It is simialr to JAVA so it is helpful for those who are  learning JAVA. It also supports object oriented programming ie u don’t need to define a function every time if u want to use instead in OOP u can write function once inside a class then u can call the function by creating an object of that class and then calling it..

to download karel, click
to install: Download an assignment from clicck(in this assiggnments)
   
Import button
After downloading both the assignment and eclipse IDE, unrar it and open Eclipse.exe, then click on the import button ----------------------------------------------------------------->


Then use the browser to find Assignment-1 folder.When you do so, Eclipse will load the starter project and display its name in the Package Explorer window like this:


Then click on the small triangle and start doing solving the problem.


Now lets do a simple Karel program : 

Q.we will solve a problem from assignment-1 ie CollectNewspaper(the documentation for the problem is available in, handouts-assignment 1)


clip of problem (we have to get the beeper):   
 Code is:
 
import stanford.karel.*;

public class CollectNewspaperKarel extends Karel{

    public void run(){
          move();
          turnRight();
          move();
          turnLeft();
          move();
          pickBeeper();
    }

    public void turnRight(){
          turnLeft();
          turnLeft();
          turnLeft();
    }


Karels running interface is :

To learn Karel download the book : www.stanford.edu/class/cs106a/book/karel-the-robot-learns-java.pdf

SHARE THIS POST:

Related Posts:

  • RGB Color Chooser Applet Java Code A RGB Color Chooser shows three sliders that the user can manipulate to set the red, green, and blue, components of a color. A color box shows the selected color, and there are three labels that show the numerical values of… Read More
  • Karel -the Robot learns Java using Eclipse Tutorial Karel The Robot is a robot simulator that affords a gentle introduction to computer programming. Users write Karel programs and feed them to the simulator to watch them execute. By solving karel problems you will build you… Read More
  • Microsoft SQL Server 2008 connection using ODBC tutorial My previous post was on SQL Server installation . Now today I will be telling how to connect your database ie SQL Server using ODBC with Netbeans. After you installed SQL Server 2008 Express successfully, now its time to … Read More
  • Merge Sort using Java with program code In computer science, merge sort or mergesort is a sorting algorithm for rearranging lists (or any such linear sequential data storage structure) into a specified order. It is a particularly good example of the divide and co… Read More
  • Regular Expressions in Java A regular expression is a kind of pattern that can be applied to text (String, in Java). Java provides the java.util.regex package for pattern matching with regular expressions. Java regular expressions are very simila… Read More

5 comments:

  1. Anyone can help? Ive tried running Karel prog on both my own copy of Eclipse and Stanfords,both result in a blank page withe the problem as the title i.e 'CollectNewspaper...'and 'File' just underneath that then the box is just white-(no Image at all! Ive tried changing the run config as explained on a few pages and the youtube video http://www.youtube.com/watch?v=jWMW2ZfYPo4 and a small variation on this but always the same outcome-the blank 'titled' box and No errors show in the Problems tab...it has me totally baffled^^,im taking a java course but i like the look and simplistic approach of karel to speed my education,Thank for reading this any help would be massive! O I'm runnin a PC on Xp pro with java7, i was wondering if i may have to downgrade to java6 but i cant see it? Eclipse Indigo and helios both result in the same-as does stanford own copy,. :s

    ReplyDelete
  2. Go here and check Lecture No. 2 It will show you how to open and run it.
    http://see.stanford.edu/see/lecturelist.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

    ReplyDelete