卡雷尔于CS1教学机器人在Java

来源:百度文库 编辑:神马文学网 时间:2024/04/28 00:54:59
Teaching CS1 with Karel the Robot in Java 卡雷尔于CS1教学与机器人在Java
Byron Weber Becker 拜伦韦伯贝克尔
University of Waterloo 滑铁卢大学
Waterloo, Ontario N2L 3G1 滑铁卢,安大略N2L 3G1
bwbecker@uwaterloo.ca bwbecker@uwaterloo.ca
Abstract摘要
Most current Java textbooks for CS1 (and thus most current courses) begin either with fundamentals from the procedural paradigm (assignment, iteration, selection) or with a brief introduction to using objects followed quickly with writing objects.最新的Java于CS1课本(因此最新的课程),开始作简短的介绍与基本面的循环,选择)或一个程序范例(转让,使用对象随即而来的写作对象。 We have found a third way to be most satisfying for both teachers and students: using an interesting predefined class to introduce the fundamentals of object-oriented programming (object instantiation, method calls, inheritance) followed quickly by the traditional fundamentals of iteration and selection, also taught using the same predefined classes.我们已经找到了第三种方法是最满意的学生对教师和:使用一类有趣的预定义介绍继承)的基本原理面向对象编程(对象实例,方法调用,随后很快通过迭代和选择的传统基础知识,还教导使用相同的预定义类。
Karel the Robot developed by Richard Pattis [5], well-known to many computer science educators, has aged gracefully and is a vital part of our CS1 curriculum.卡雷尔的Pattis理查德机器人开发[5],众所周知的许多计算机科学的教育工作者,老了优雅,是一个于CS1课程的重要组成部分,我们。 This paper explains how Karel may be used and the advantages of doing so.本文介绍了如何使用和卡雷尔可能这样做的优点。
1 Introduction 1简介
We began the development of our Java-based introductory programming course for CS majors and Math students in 1998. 1998年我们开始我们的Java为基础的学生介绍数学在编程过程中对于CS专业与发展。 At the outset we realized the obvious: we would have to make a paradigm shift from procedural programming to object-oriented programming.在一开始我们就实现了明显的:我们将不得不作出一个面向对象编程模式的转变,从程序设计到对象。 What caught us off guard was the second paradigm shift required - the paradigm for teaching an OO language (Java) is different from teaching a procedural language such as Pascal, C or even C++.是什么把我们措手不及的是第二范式转变需要-的)范例教学面向对象语言(Java是从教学+不同的C +程序语言,如帕斯卡尔,C或偶数。
In our first attempt at teaching the course we used a textbook which was very well-written but placed objects relatively late - about where a Pascal text would place records.在我们的第一次尝试在教学过程中,我们使用一晚这是很好的教材编写,但放置的对象比较-关于一个Pascal的案文将在那里举行的记录。 We were uneasy with this, feeling that objects really ought to be introduced and used from day 1, but as we couldn't find a text which supported this we made an attempt to provide our own examples parallel to the text.我们不安的,感觉的对象真的应该引进和1所使用的一天,但因为我们无法找到一个文本,支持这一点,我们尝试去提供我们自己的例子文本平行。
It was a disaster.这是一个灾难。 The fundamental object-oriented concepts (object instantiation, method calls, inheritance) came too late in the course.最根本的面向对象概念(对象实例,方法调用,继承)的过程来得晚了。 Students didn't have enough time to master the topics.学生没有足够的时间来掌握主题。 This was worsened by the fact that most of our students come with some (procedural) programming experience from high school.这是恶化的事实,即大多数学生对我们提出一些编程经验的高中(程序)。 When the early part of the course focused on iteration and selection (without objects, except for the little we provided ourselves), most students thought they already knew it all.当早期的课程侧重于迭代和选择(无对象,我们除了提供自己的小),大多数学生认为他们已经知道这一切。
After reviewing textbooks again, our standard rant went like this: "Textbooks start with a vague, airy-fairy descriptions of objects (Java is an object-oriented language after all), but then go into primitive types. No objects. Chapter 3 is selection using payroll as an example. No objects . Chapter 4 is iteration - no objects . Suddenly, in chapter 5, students are expected to use and write objects. And they say, `Remind me what an object is... What are they good for? How do I use them? What are the characteristics of a good object?'."在审查教科书再次,我们的标准咆哮是这样说的:“教科书的对象开始模糊,通风,仙女的说明(Java 是一种面向对象的语言毕竟),但随后进入基本类型3。 号为对象。章工资作为一个例子。 无选择的对象 。使用第四章是迭代- 。。 没有突然,在第五章中,学生要使用的对象和对象,并写出他们说,'我提醒的对象是什么...他们是什么好处?如何使用?什么是好的对象的特点了?'。“
Shortly thereafter we discovered Karel the Robot in Karel++: A Gentle Introduction to the Art of Object-Oriented Programming [1], the most recent incarnation of Rich Pattis' idea from the early `80's.此后不久,我们发现卡雷尔的机器人在卡雷尔+ +:一个温柔的艺术介绍到面向对象编程 [1],Pattis'的最新化身丰富的想像力,从早期`80。 It was a revelation to us. This was how we wanted to teach Java.这是一个启示给我们。 这是我们如何想教的Java。 There were just two problems. First, the book is really oriented towards C++ rather than Java.只是有两个问题。第一,这本书实在是面向C + +而不是Java。 Second, it's only the introduction to an introductory course, covering the first 4-5 weeks.其次,它只是介绍课程介绍,包括第一次4-5个星期。
After convincing the publisher to allow us to translate Karel++ to Java, adding a second textbook, writing software to support Karel, and rewriting all our lectures, we have a course we are very happy with.经过说服出版商让我们翻译卡雷尔+ +到Java,增加第二教材,编写软件,以支持卡雷尔,并改写我们训话,我们有我们当然非常高兴。 The remainder of this paper discusses Karel the Robot and the advantages we see in starting the course by using an interesting object.本文的其余部分讨论这个卡雷尔的机器人和对象的优势,我们看到有趣的过程中开始使用的。
2 Karel and Karel's World 2卡雷尔和Karel的世界
Karel inhabits a very simple world.卡雷尔栖息一个很简单的世界。 There are avenues running north and south numbered one to infinity and streets running east and west, also numbered one to infinity.途径有编号的贯通南北的街道一到无穷大,运行东,西,同样编号一到无穷大。 Walls may be placed between the avenues or streets, running parallel to them.墙壁可放置或街道之间的渠道,向他们平行。 Beepers may be placed on the intersections of the avenues and streets.寻呼机可能被放置在街道和路口的途径。 Several robots may exist within the same world.几个机器人可能存在于同一个世界。
Within this world, robots may move forward from one intersection to an adjacent intersection unless the way is blocked by a wall.在这个世界里,机器人可以从一个十字路口向前推进到相邻的路口,除非是墙的方式阻止了。 They may turn left 90 degrees to face a different direction.他们可能左转90度,面对不同的方向。 Robots may pick up a beeper from their current intersection (if one or more are present), or place a beeper on their current intersection (provided they are carrying at least one beeper). Robots may carry beepers between intersections in their "beeper bag" and may detect whether or not their beeper bag is empty.机器人可以拿起当前路口一个蜂鸣器从他们(如果存在一个或多个),或将蜂鸣器)一个蜂鸣器他们目前的交点(须携带至少一个。机器人可携带传呼机路口之间的“蜂鸣器袋”并可以检测是否他们的蜂鸣器袋子是空的。
Robots may also determine if they are facing North (or any of the other 3 compass positions), if there is a beeper on the current intersection or if there is another robot on the current intersection.机器人也可以判断他们所面对的北(或3指南针任何其他位置),如果有一个路口蜂鸣器当前或是否有另一个路口机器人的电流。
The world and the actions of any robots within it are shown visually on the computer monitor.机器人的世界,任何在它的行动的监测显示在计算机上直观地。 A sample is shown in Figure 1.示例见图1。 If the goal of the robot is to pick up all of the beepers, then one possible solution is shown in Figure 2. This example may be seen running as an applet athttp://www.math.uwaterloo.ca/~bwbecker/papers/sigcse2001/karel/samples.html . A second example shows four robots solving the same problem.如果机器人的目标是要拿起传呼机所有的,那么一个可能的解决方案如图2所示。这个例子可以看出小程序在运行作为一个http://www.math.uwaterloo.ca/?bwbecker / papers/sigcse2001/karel/samples.html 。第二个例子显示了四个机器人解决同样的问题。 A third example uses threads so that four robots work simultaneously (instead of taking turns) to solve the problem.第三个例子使用线程,使四个机器人同时工作(而不是轮流),以解决这个问题。
 

Figure 1: An initial situation with one robot (an arrowhead), twelve beepers (circles) and ten walls (rectangles). 图1:矩形)与一个机器人的初步情况(箭头),12传呼机(圆圈)和10墙(。
package HarvestSquare;包HarvestSquare;import cs1Lib.karel.Robot;进口cs1Lib.karel.Robot;import cs1Lib.karel.World;进口cs1Lib.karel.World;public class Main extends Object公共类主要对象扩展{ {public static void公共静态无效main(String[] args)的main(String []参数){ // Instantiate a new world, initialized with walls and {/ /实例化一个新的世界,墙壁和初始化// beepers as specified in a file. / /寻呼机所指明的文件。World square = new新的世界广场=World("HarvestAroundSquare.txt");世界(“HarvestAroundSquare.txt”);// Instantiate a new Robot and add it to the world at / /实例化一个新的机器人,并把它添加到整个世界// the corner of 2nd avenue and 3rd street facing east. / /在第二大街的拐角处和三街向东。HarvesterRobot karel = HarvesterRobot卡雷尔=new HarvesterRobot();新HarvesterRobot();square.addRobot(karel, 2, 3, square.addRobot(卡雷尔,2,3,World.EAST); World.EAST);// Move into the intial position, then pick the beepers / /移动到初始位置,然后从中挑选寻呼机// and turnoff. / /和倒胃口。karel.move(); karel.move();karel.pickBoundedRectangle(); karel.pickBoundedRectangle();karel.turnOff(); karel.turnOff();} }} }/** A new kind of robot which knows how to harvest beepers / **一个新型机器人它知道怎样去采集寻呼机laid out in a rectangle with a wall marking the end of each在矩形中奠定了一个标记,每个端墙side.一边。 */ * /class HarvesterRobot extends Robot类HarvesterRobot扩展机器人{ {/** Pick the beepers in a rectangle where the end of each / **挑选寻呼机在一个矩形,每年年底side is bounded by a wall.一边是四周的墙上。 */ * /public void pickBoundedRectangle()公共无效pickBoundedRectangle(){ for(int side=0; side<4; side++) {为(int端= 0;方<4;方+ +){ this.pickUntilWall(); {this.pickUntilWall();this.turnLeft(); this.turnLeft();} }} }/** Pick one beeper from each intersection between the / **选择一个蜂鸣器各路口之间current location and the nearest wall in the direction faced当前位置和方向,在最近的墙壁所面临by the robot.由机器人。 */ * /private void pickUntilWall()私人无效pickUntilWall(){ while (this.frontIsClear()) {而(this.frontIsClear()){ this.move(); {this.move();this.pickBeeper(); this.pickBeeper();} }} }} }
Figure 2: One solution to pick up all the beepers in the world shown in Figure 1. 图2:一个解决方案,拿起图1所示的所有世界的寻呼机英寸
3 Course Outline 3课程大纲
A typical CS1 course would use Karel for the first four to five weeks to introduce objects, inheritance, selection, iteration, and related concepts. After this introduction, robots would be left behind in favor of a wide range of examples.一个典型的于CS1当然会使用两周卡雷尔首四,五,介绍对象,继承,选择,迭代和相关概念的介绍。在此之后,机器人将被留在例子赞成范围很广。
3.1 Week 01: Instantiating and Using Objects 3.1周01:实例化和使用对象
In the first week we describe robots and the world they inhabit.在第一个星期,我们描述的机器人和他们所居住的世界。 After reviewing several simple programs, students understand how to instantiate objects, invoke the objects methods and that it's possible to have several objects belonging to the same class, each with its own state.在审查了几个简单的程序,学生了解如何实例化对象,调用对象的方法,它可能有自己的国家几个对象属于同一类的,每个。 A typical homework problem is to instruct one or more robots to perform a fixed task such as retrieve a beeper from a given intersection.一个典型的家庭作业的问题是指示一个或多个机器人完成既定交会定点的任务,如从一个检索一个蜂鸣器。
3.2 Week 02: Extending Existing Classes 3.2周02:扩展现有类
During the first week students often ask "Can a robot turn right?" (or move forward more than one intersection at a time or ...) - which they can't.在第一周的学生经常会问:“一个机器人右转?”(或移动一个十字路口提出更多的时间大于或...) -这是不可能的。 This is the perfect opportunity to extend the Robot class with new behaviors.这是一个完美的机会,扩大与新行为的机器人类。 For instance, to create a new class of robots capable of turning right, we write例如,要创建一个新类右转对机器人的能力,我们写
import cs1Lib.karel.Robot;进口cs1Lib.karel.Robot;public class RightRobot extends Robot公共类RightRobot扩展机器人{ public void turnRight() {公共无效turnRight(){ this.turnLeft(); {this.turnLeft();this.turnLeft(); this.turnLeft();this.turnLeft(); this.turnLeft();} }} }
This basic idea is quickly expanded into step-wise refinement to solve a more complex problem such as picking up all the beepers in a fixed-size rectangular area.这个基本的想法是迅速扩大到逐步的完善,以解决大小的矩形区域,一个更复杂的问题,如在一个固定的采摘了所有的寻呼机。 A natural extension, parameterized methods, is deferred to leave sufficient time for discussing inheritance and step-wise refinement thoroughly.一个自然延伸,参数化方法,是推迟到足够的时间彻底离开细化讨论继承和分步进行。
3.3 Week 03: Selection and Iteration 3.3周03:选择和循环
In the third week we tackle selection and iteration.在第三个星期我们面对的选择和迭代。 The Robot class includes several methods which return Boolean values, including frontIsClear (is there a wall immediately in front of the robot?), nextToABeeper (is there a beeper on the same intersection as the robot?), facingNorth (is the robot facing North?), and anyBeepersInBeeperBag (is the robot carrying one or more beepers?).该机器人类包括这几种方法,包括frontIsClear返回布尔值,(是否有壁机器人立即前面的?),nextToABeeper(有一个机器人蜂鸣器作为相同的交集?),facingNorth(是机器人朝北?),和anyBeepersInBeeperBag(是一个或多个机器人携带传呼机?)。 These allow a number of interesting problems such as the one shown in Figure 1, constructing a histogram out of beepers, or having the robot run a hurdles race where hurdles are represented by walls.这允许一个如图1所示一个数字作为如此有趣的问题,构建出一个直方图传呼机,或有机器人运行跨栏障碍是墙的地方代表。 Value-returning methods and Boolean expressions fit naturally with the discussion of the provided predicates.返回值的方法和布尔表达式谓词自然与提供适合讨论的。
3.4 Week 04: Methods with Parameters 3.4周04:与参数测试方法
Methods can be made much more general, of course, with parameters.方法可更普遍,当然,带参数。 Simpler problems include a move method which takes an integer distance parameter or a harvestPlot method which collects all the beepers from an area defined by the parameters.简单的问题包括移动方法,该方法接受一个整数距离参数或harvestPlot方法,收集的所有区域定义的参数的寻呼机的。 A more complex example is a Contractor robot which has several subcontractors to help build a house.一个更复杂的例子是一个机器人有几个承包商的分包商,以帮助建立一所房子。 The subcontractors are passed via parameters and give a good opportunity to compare passing primitive types with passing reference types.分包商通过参数传递,给一个好机会,通过比较原始的类型与引用类型传递。
3.5 Week 05: Instance Variables 3.5 05周:实例变量
In the last week spent with robots, we extend the Robot class with additional instance variables.在度过了机器人一周最近,我们扩展其他类的实例变量与机器人 。 The classic example is a MeteredRobot which keeps track of how many moves it makes so that a customer can be charged for its services.典型的例子是一个MeteredRobot这使服务跟踪它使多少动作,使客户可以为它充电。 After this relatively brief example we quickly move to other, non-robot, examples such as a date or bank account class.这个相对简单的例子后,我们迅速转移到其他非机器人,类的例子,如日期或银行帐户。
After introducing the fundamentals of object-oriented programming, the remainder of the course focuses on a wide range of topics including arrays, graphical user interfaces, and object-oriented design.在介绍了面向对象编程的基本知识对象,其余课程的重点是面向设计宽范围的议题包括数组,图形用户界面和对象。
3.6 Discussion 3.6讨论
Taking five weeks to cover these topics seems slow, but it's not.以五周的这些主题似乎慢,但事实并非如此。 Topics such as procedural decomposition, parameters, iteration and selection are hard for most beginners.选择主题,如程序分解,参数,迭代,难以对大多数初学者。 They were hard back in the days of Pascal - and that hasn't changed just because we have moved to object-oriented languages.他们很难帕斯卡尔回天在-这并没有改变只是因为我们已经搬进面向对象的语言。 In the Pascal predecessor to this course we spent two weeks on control structures, two weeks on subprograms, and another week on records.在Pascal的前身本课程中我们花了控制结构,两周子程序两个星期,另一周的纪录。
Many courses may be able to move faster.许多课程可能可以移动得更快。 In fact, we do.事实上,我们所做的。 By 1995 we observed that most of our students had previous programming experience.到1995年,我们观察到,大多数学生对我们曾经有过编程经验。 After making this a prerequisite for our "first" course (and providing a remedial course for those who didn't have it) we shaved a week off the schedule suggested above.对于这样一门课程的先决条件为我们的“第一”(当然,对于那些提供补救谁没有它),我们剃一个星期,上述建议的时间表。
Some people assume robots are over-used and that students soon tire of them. This is not the case.有些人认为机器人是过度使用,使学生很快就感到厌烦的。这种情况并非如此。 We could not use them longer, but just over four weeks is not too long.我们可以不使用它们的时间,但是刚刚超过4个星期的时间不会太长。 Students enjoy the visual aspects and the anthropomorphism they make possible.学生享受视觉方面和拟人,他们成为可能。 In the course evaluations many students say they thoroughly enjoyed the robots; few mention them negatively.在课程评价许多学生说,他们尽兴的机器人,很少提及他们的负面影响。
We do need to mention often in class that we are only using robots as a tool to learn about programming. 我们的确需要经常提到的类,因为我们只使用编程机器人作为一种工具来学习一下。 It's not a course about robots - it's a course about programming!这不是一个关于机器人的过程-这是一个程序设计课程呢! We reinforce this with frequent allusions to other possible classes such as Employee or Date or Account , indicating that the concept under discussion applies to those situations, too.我们加强考虑这一日期或作为雇员或其他可能频繁的典故类等,这表明该讨论的概念适用于这些情况下,太。
4 Advantages四优势
There are a number of advantages to using Karel the Robot to introduce objects.有很多优点的使用卡雷尔机器人介绍对象。 A number have been alluded to already.一个数字已经提到了。 They are more carefully enumerated here.他们更仔细地列举在这里。
4.1 Object-Oriented Fundamentals First 4.1面向对象的基础第一
Karel the Robot emphasizes the fundamental concepts in OO programming (instantiating objects, invoking methods, extending existing classes) from the beginning.卡雷尔机器人强调在面向对象编程的基本概念(实例化对象,调用方法,扩大现有班)从一开始。 It's important that students be able to practice these concepts as long as possible and that they not be left to the middle or end of the course where they might be skimmed over lightly if time is tight.重要的是,学生能够实践这些概念很紧,只要可能的,而且他们没有留给时间的中间或结束的课程,在这里他们可能会掠过掉以轻心。
Of course the foundations of procedural programming (selection, iteration, procedural decomposition) are also very important.当然分解)的基础的程序设计(选择,迭代,程序也非常重要。 The Robot class allows them to be naturally introduced with the OO fundamentals so that they, too, can be practiced throughout the course.该机器人类允许它们是自然的过程中实行的面向对象的基础,使他们也能做到各地。
Many courses reverse these sets of fundamentals - introducing selection and iteration before using objects, sometimes treating objects as fancy Pascal records.许多课程扭转这些基本面套-迭代引进前的选择和使用对象,有时治疗记录对象作为花式帕斯卡。 There are two problems with this approach: a paradigm shift and missed opportunities.有两种方法存在的问题是:一个模式的转变和错过的机会。
Students are often asked to write programs typical of those in chapter 3 of [3].学生经常被要求写] [3方案典型的3章中的那些。 These are programs which count, sum or generate comments based on user input.这些节目数量,金额或产生输入用户意见的基础上。 None of these programs use objects except for System.out , strings, and (once or twice) an instance of NumberFormat .这些方案均使用的NumberFormat对象除了System.out的 ,字符串和(一次或两次)的一个实例。 Later, the students must shift from a "do it all myself right here" paradigm to a "find/build some objects to cooperate in getting the job done" paradigm.后来,学生必须从一个“我做这一切就在这里”模式向“查找/创建一些对象进行合作,获得完成工作的”模式。
The missed opportunities of this approach are in the richness of tasks that can be done with existing objects.这种方法的错失机会在现有的丰富的对象与任务可以做。 Why should students be summing numbers when they could be doing more interesting things which are pedagogically just as valid?为什么要学生人数时,他们将总结可以做更多有趣的事情就是为有效这是教学上?
Another common approach in existing textbooks is to make extensive use of System.out and the String class as example objects.另一个现有的教科书中常用的方法是让广泛使用System.out和String类的对象实例作为。 These programs use objects but the object creation is hidden by the run-time system (in the case of System.out ) or special language support (strings). Creating objects - including multiple instances from the same class - is an important part of students understanding what objects are and how they work.这些程序使用的对象,但对象的创建)隐藏在运行时系统(在该个案的System.out)或特殊的语言支持(字符串- 。 创建对象包括同一类的多个实例的-是一个学生的重要组成部分了解哪些对象以及它们如何工作。
By using a sufficiently complex and interesting predefined class such as Robot students can begin using the OO fundamentals from the beginning and avoid a paradigm shift later on.通过使用一个足够复杂而有趣的预定义类,如学生可以开始使用机器人从一开始就面向对象的基本面,避免了模式转变以后。
4.2 Robots are Visual 4.2机器人视觉
The fact that robot worlds have a visual representation provides a number of benefits.事实上,世界上有一个机器人视觉表现提供了许多好处的。
Many problems can be specified using a picture of the initial situation and another of the final situation, plus a few lines of text.许多问题都可以指定使用情况的初始图片和情况的另一项决赛中,加几行文字。 We find that students have fewer questions about homework problems specified this way.我们发现学生有这样的问题也较少具体问题有关的功课。 The animation provides visual feedback on the correctness of an algorithm.该动画提供了一个可视化的反馈算法的正确性。 If the student's program doesn't result in the same image as the problem statement, there must be a bug (of course, just because it looks the same doesn't mean it was done right...).如果学生的程序不会导致问题的声明相同的图像,必须有一个错误(当然,只是因为它看起来是一样的,并不意味着它是做正确的...). Students can often see where their program goes wrong simply by watching the animation.学生们可以经常看到他们的程序出错的地方简单地看动画。 Since the human brain is highly optimized to process visual input this is faster and easier than, say, scanning a list of numbers from a console program.由于人的大脑是高度优化,处理视觉输入,这是更快,更容易,说比,扫描程序列表的数字,从一个控制台。 Since robots provide output visually, traditional input and output can be delayed.由于机器人视觉提供输出,传统的输入和输出可以被延迟。 This is particularly attractive in Java where I/O is cumbersome, at best.这是Java的吸引力,尤其是在I / O是繁琐,最好的。
4.3 Robots are Fun 4.3机器人很有趣
Robots are fun!机器人是有趣! This is, perhaps, the biggest advantage of the approach. Students enjoy directing robots to do various tasks.这,也许,这种方法最大的优势。学生喜欢指挥机器人来执行各种任务。 Acting out a program in class is more fun than tracing a listing.在课堂上表演了节目更比跟踪一上市乐趣。 Visual output is more fun than textual output.视频输出更输出乐趣比文本。
5 Difficulties五难点
The biggest difficulty with this approach is in the transition from our translation of Karel++ to another textbook for the last two-thirds of the course.这种方法最大的困难是课程与在过渡,从我们的翻译三分之二卡雷尔+ +到另一个教材,最后两个。 No matter which text we choose, there is a mismatch between what we have taught using Karel and the presentation of the other textbook.无论我们选择哪个文本,有一本教科书,我们有什么之间的不匹配使用卡雷尔教授和其他演示文稿的。 We are working on producing a full textbook based on the Karel material to overcome this difficulty.我们正在制作一个完整的教材难度卡雷尔材料的基础上,克服这一点。
A second difficulty is that some students are reluctant to believe that everything they learn about robots transfers to other object-oriented programs as well.第二个困难是,有些学生不愿相信这一切,他们也了解机器人转移到其他对象为导向的课程。 A few brief references such as "We create a new robot with an instruction such as Robot karel=new Robot() . If we were writing a payroll system we might create an object to represent an employee with Employee sue=new Employee(); " is enough for most students.一个简短的引用,如“我们创造了一个()新的机器人,如与指令机器人卡雷尔=新的机器人)。如果我们正在写一个工资管理系统,我们可以创建一个对象来代表员工与员工新员工起诉=(; “是足以让大多数的学生。
6 Related Work 6相关工作
Since we developed this course textbooks have, in general, moved objects earlier.由于我们开发了这个课程教科书,一般来说,移动的物体前面。 Most, however, use a scattering of Java classes such as String or Random which we find inferior to the approach recommended here.但是,大多数在这里使用散射字符串或Java类,如随机 ,我们发现劣的办法推荐。
A few textbooks come closer.一些教科书走近。 Slack [7] uses turtle graphics rather than a robot but uses a spiral approach.斯莱克[7]使用机器人龟,但使用的图形,而不是一个螺旋方式。 Chapter 2 is a difficult chapter, packed with concepts illustrated with turtle graphics.第二章是一个困难的章节,图形与包装甲鱼的概念说明。 Chapters 4, 5, 7 and parts of 10 then come back to cover the concepts in more depth.第4章,第5,第7和第10部分,再回过头来覆盖的概念更深入研究。
Morelli [4] uses a "CyberPet" as an interesting example to illustrate object-oriented fundamentals as well as iteration and selection.莫雷利[4]使用迭代和选择“CyberPet”作为一个有趣的例子来说明面向对象的基本原理以及。 The difference is that it is not a pre-defined class, as are the robots.所不同的是,这不是一个预先定义的类,因为是机器人。 Instead students develop it as they go along.相反学生培养它,因为他们走。
Wu [8] gives a well-crafted rationale for using objects early.吴[8]给出了使用对象早日精心制作的理由。 The objects his students use, however, are a simplified interactive I/O library used in the context of other problems.他的学生使用的对象,却是一个简化交互的I / O库的问题,用在其他方面的影响。
Otterbein College uses Karel the Robot as an introduction to programming. They have a sophisticated environment developed by Duane Buck which supports a Java-like syntax (as well as Pascal and Lisp) and has an integrated compiler and execution environment.奥特伯恩学院使用的编程介绍卡雷尔作为一个机器人。他们有一个复杂的环境中)而开发的杜安巴克支持Java的语法(以及Pascal和Lisp和有一个集成的编译器和执行环境。 Differences from our approach is that our students use a Java development environment, importing the necessary classes rather than one environment for Karel and a different one for other programs.从我们的是方法上的差异,我们的学生使用Java开发环境,导入其他程序所需的类,而不是一个一个的环境,卡雷尔和不同。 In the Otterbein environment only a single robot can be used in any given program.在奥特伯恩环境只有一个机器人可以用在任何给定的程序。 The environment is available athttp://math.otterbein.edu/JKarelRobot/ . Their larger approach is discussed in [2].环境是可以在http://math.otterbein.edu/JKarelRobot/ 。它们的较大方法]讨论[2。
Joseph Bergin has made his own translation of Karel++ to Java available on the web, along with classes implementing the robot.约瑟夫贝尔然提出了他自己的翻译卡雷尔+ +到Java网站上提供的,随着阶级实施机器人。 It may be found athttp://csis.pace.edu/~bergin/ KarelJava/Karel++JavaEdition.html .可以发现在http://csis.pace.edu/?贝尔然/ KarelJava /卡雷尔+ + JavaEdition.html 。
The web page for our own CS1 course is athttp://www.student.math.uwaterloo.ca/~cs130/ .该课程于CS1为我们自己的网页是在http://www.student.math.uwaterloo.ca/?cs130 / 。
Rich Pattis, the originator of Karel the Robot, has extended the idea into artificial life simulations.丰富Pattis,机器人的鼻祖卡雷尔,已经扩展到模拟的人工生命的想法。 The result is a much more complex set of classes for students to master, but one that also affords many more possibilities [6].其结果是一系列复杂得多的硕士班学生,但一个也提供了更多的可能性[6]。
7 Conclusions 7结论
We have been extremely pleased with using an interesting predefined class (Karel the Robot) to teach object-oriented fundamentals (object instantiation, method calls, inheritance) and traditional procedural fundamentals (iteration, selection) early in the course.我们一直非常高兴,用了一个有趣的预定义类(卡雷尔机器人)教导面向对象基础(对象实例,方法调用,继承)和传统的程序基础)早在课程(迭代,选拔。 The result has been a course that is fun for both students and instructors, and where students understand the fundamental concepts early, allowing them to approach advanced topics with confidence.其结果是一个有趣的课程,是早期为学生和教师,和学生们理解的基本概念,让他们的做法有信心高级主题。
References 参考文献
[1] Bergin, Joseph, Mark Stehlik, Jim Roberts, and Richard Pattis. Karel++: A Gentle Introduction to the Art of Object-Oriented Programming . [1]贝尔然,约瑟夫,马克斯特赫利克,吉姆罗伯茨和理查德Pattis:。卡雷尔+ +一个温柔的艺术介绍到编程的面向对象的 。 John Wiley & Sons, 1997.约翰Wiley&Sons出版,1997。
[2] Buck, Duane and David J. Stucki. [2]降压,杜安与David J.斯塔基。 Design Early Considered Harmful: Graduated Exposure to Complexity and Structure Based on Levels of Cognitive Development. SIGCSE Bulletin 1 (2000), p.早期的设计是有害的:毕业于暴露结构的复杂性和认知发展水平的页。SIGCSE公告 1(2000), 75-79. 75-79。
[3] Lewis, John and William Loftus. Java Software Solutions. Addison-Wesley, 2000. [3]刘易斯,约翰和威廉洛夫特斯。Java的软件解决方案。Addison - Wesley出版社,2000。
[4] Morelli, Ralph. Java, Java, Java: Object-Oriented Problem Solving . [4]莫雷利,拉尔夫:。爪哇,爪哇,Java的面向对象解决问题 。 Prentice-Hall, 2000. Prentice - Hall出版社,2000。
[5] Pattis, Richard E.. Karel the Robot: A Gentle Introduction to the Art of Programming , John Wiley & Sons, 1981. [5] Pattis,理查德E:。卡雷尔介绍温柔的机器人在 1981年艺术规划 ,威利父子。
[6] Pattis, Richard E. Teaching OOP in C++ Using an Artificial Life Framework. SIGCSE Bulletin 1 (1997), p. [6] Pattis,理查德体育教学面向对象的C + +利用人造生命框架。SIGCSE公告 (1997年),第 39-43. 39-43。
[7] Slack, James M.. Programming and Problem Solving with Java . Brooks/Cole, 2000. [7]懈怠,詹姆斯米。 规划和解决问题的 2000年与Java。布鲁克斯/科尔。
[8] Wu, C. Thomas. An Introduction to Object-Oriented Programming with Java . [8]吴尔托马斯。 一个Java的介绍对象与面向对象编程 。 WCB/McGraw-Hill, 1999.水利局/麦格劳希尔,1999。