Karel J. Robot
A Gentle Introduction to the Art of Object-Oriented Programming in Java

This manuscript has not been published. It is Copyright, Joseph Bergin.

Some of you are using this manuscript in your courses. This is fine if you are a non-profit educational institution. However, note that there are few exercises here. The exercises are in the book Karel++. If you use this manuscript it will be helpful to the authors and to your students if you have at least a few (more than one) copies of the printed book available for your students. That way they have the exercises and the authors (and publisher) get paid something for our efforts.

If you are using this manuscript I'd like to know about it. Please send me email at berginf@pace.edu.

Dedication | Teaching Notes | Table of Contents
Simulator | Use with JJ | Use with BlueJ | Extras

 

 

Changes coming to Karel J Robot

In preparation for publishing this as a book some decisions are being made that you should be aware of. Note that I have no publication date or firm plan yet, but the manuscript is being updated. The online version will probably not change to reflect these decisions, however. When it is published, most of the manuscript will no longer be available here and I will ask that those who mirror it update their pages accordingly for copyright reasons. The list of decisions below may change as we proceed.

 If you feel strongly about any of these issues, please feel free to contact me.

Kristen Nygaard Image
Dedication. The authors would like to dedicate this work to the memory of Kristen Nygaard, who, along with his friend and colleague Ole-Johan Dahl, invented object-oriented programming in the 1960s and who worked since then to refine and extend it. Kristen was an interesting and lively person who worked his entire life to make things better for others, both in technology and otherwise. We, who came to know him, miss him and his continuing inspiration greatly. He died suddenly in August 2002 at the age of 75.

 

 

NOTE. See below for information about a simulator in 100% pure Java.

 

Teaching Notes (new)


Preface

1 The Robot World

2 Primitive Instructions and Simple Programs

3 Extending the Robot Programming Language

4 Polymorphism

Optional Section on Linked Lists (before selection)

5 Conditionally Executing Instructions

Optional Section on Recursion (before iteration)

6 Instructions That Repeat

7 Advanced Techniques for Robots

8 Concurrent Robot Programs

9 Moving Beyond Robots to Objects

10 Input, Output, and Exception Handling

11 Safe Concurrent Programming with Robots

Note that this version may contain several minor errors. It has not been through a rigorous editing process. I would appreciate comments and bug reports sent to me at berginf@pace.edu. Thanks.


There is a set of Java classes that you can use to run Karel J. Robot programs written in 100% pure Java (see below). Here is a (South facing) robot trying to place some beepers in the world.

 

Image of Karel in a world with two beepers and some walls

This version is very sophisticated and may be used to run concurrent robot programs as well as sequential ones. An example is provided (Philosopher.java) that illustrates the dining philosopher problem.


Simulator Available

A new simulator with a world builder is now available.

Note that the worlds read and written by this simulator are not compatible with those of the Karel ++ versions. Here we use simple text files, where in the earlier work we used a proprietary format.

You will need a text editor or IDE to create java programs for this simulator. You will also need Java.

Another Simulator

Here is another simulator independently developed in Germany by Christoph Bockisch. This one is built with Swing and uses features of Java 1.4, so it only runs on the latest Java versions. I have not been able to test this. It is faithful to the current manuscript, in that the user writes a "task" not a "public static void main..." There is a preprocessor to translate it to real Java. Note that the book, when published will probably also be real Java, and "task" and "loop" will be replaced by their true Java equivalents. This simulator also does not support the functionality needed in the later chapters of the manuscript.


Karel J. Robot and JJ

JJ is an online interactive Java educational environment that you can use with just a Java enabled browser. Karel J. Robot is now available interactively via the JJ system at http://www.publicstaticvoidmain.com/.

You can test it at
http://www.publicstaticvoidmain.com/cgi-bin/sfjj.cgi?freeschool=KarelJRobot&file=introToKarel.java

 Karel J. Robot is JJ enabled (logo)


Karel J. Robot and BlueJ

BlueJ (http://www.bluej.org/) is a Java environment for novices. On the IDE page you can find a link to instructions on how to make it work with Karel J. Robot.

bluej logo


Thanks to Trevor Gosbell from Australia for a very simple Introduction to Karel J Robot using BlueJ

Extras

Here is an exercise that you can do after completing the first seven chapters of Karel J. Robot. The Lost Beeper Mine Adventure.

Some additional exercises were written for Karel++. They work with Karel J. Robot just as well. Note, however, that Chapters 5 and 6 in the printed Karel++ corresponds to Chapters 6 and 7, respectively, in Karel J. Robot. Additional Exercises.

There are some Additional Materials available that were produced by other people.

There are some Additional Classes available that you might want to use with your Robot programs.

Here is a Role-Play Exercise you can use to introduce Karel J. Robot and some ideas of Object-Oriented Programming. Thanks to Joseph A. Tosh for this.

Karel J Robot as a Turing Machine

Some additional ideas about using Polymorphism (see Chapter 4) is now available.

Karel J Robot is smarter than I thought. It can now Calculate PI. Thanks to Dan Eliot of Azusa Pacific University and El Dorado High School for providing this neat project for students.

There is now a ChangeHistory page for the simulator and for these pages.


Last Updated:October 12, 2003

Back to Joseph Bergin's Home Page.