This document provides instructions for downloading and installing Eclipse, the integrated development environment (IDE) that students will use for CS106A assignments. It describes downloading Eclipse from the course website, installing it on Mac and Windows systems, and setting up the Stanford Editor perspective for a simplified interface focused on programming. Students are advised to import provided "starter projects" into Eclipse for each assignment rather than creating projects from scratch. The document also notes that submitting assignments requires both electronic submission through Eclipse and a hard copy component.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
86 views19 pages
Downloading Eclipse
This document provides instructions for downloading and installing Eclipse, the integrated development environment (IDE) that students will use for CS106A assignments. It describes downloading Eclipse from the course website, installing it on Mac and Windows systems, and setting up the Stanford Editor perspective for a simplified interface focused on programming. Students are advised to import provided "starter projects" into Eclipse for each assignment rather than creating projects from scratch. The document also notes that submitting assignments requires both electronic submission through Eclipse and a hard copy component.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19
Mehran Sahami! Handout #5!
CS 106A! September 26, 2007!
Downloading Eclipse! 1YGLSJXLMWLERHSYX[EW[VMXXIRF].YWXMR1ERYWERH&VERHSR&YVV ! ! This quarter we`ll be using StanIord`s customized version oI Eclipse to build our! programs. Eclipse is an enormously popular industrial strength Java environment with! many, many Ieatures. Fortunately, Eclipse is also open sourceanyone is Iree to change! Eclipse to work the way they want. We have taken advantage oI that Ireedom to install! special StanIord Ieatures into Eclipse, to tailor it speciIically Ior CS106A. This document! gives instructions on how to get starting using Eclipse, and its StanIord Ieatures in! particular. II you run into any trouble installing Eclipse, please email Ben Newman at! [email protected].! ! Installing Eclipse! BeIore you begin to write programs Ior Karel or Java, you will need to obtain a copy oI! Eclipse Irom the CS106A course website. The process Ior downloading Eclipse depends! on what system you are using. The instructions Ior the Macintosh are shown in Figure 1,! and those Ior Windows machines appear in Figure 2. On either platIorm, the process may! take a while, so be patient!! Figure 1. Instructions for downIoading EcIipse on a Macintosh Our version oI Eclipse will only work on Mac OS X version 10.4 or higher. II you! don`t have that version oI the operating system (or you are running OS 9), you`ll need! to either upgrade or do your class work in a public cluster.! ! 1.! Get Eclipse from the CS 106A website.!BeIore you begin to write your Iirst Java! or Karel program, you will need to obtain a copy oI Eclipse Irom the CS106A! course website. To do so, go to!http://www.stanford.edu/class/cs106a, click! on!Software!and then click on!Stanford!EcIipse!for!Macintosh!OS X, and save the Iile to! somewhere on your hard drive!(or it may automatically get saved to your Desktop).! 2.! Install Eclipse.! AIter you have completed the!download, you may Iind that you! either you have a Iolder named!eclipse!or an!eclipse.dmg!Iile.! a. II you have the! eclipse.dmg! Iile, it! is a virtual disk that contains a single! Iolder named! eclipse. Double-click the! eclipse.dmg! Iile, andaIter a Iew! secondsthe! eclipse-mac-distribution! disk will appear in the Finder! (that`s how! .dmg! Iiles work). The! eclipse! Iolder is inside the disk.! II you! didn't the!eclipse.dmg!Iile, but rather iust saw a Iolder named!eclipse!aIter! you Iinished the download, you can skip to Step b, below.! b. Drag!the!eclipse!Iolder to the!Applications!Iolder.! 3.! Create a shortcut.! Open the! eclipse! Iolder (the one you iust dragged into the! Applications!Iolder), and drag the square Eclipse icon to your dock.! 4.! Make sure you have the 1ava version 1.5 or higher.! Many recently purchased! Macs will come with Java version 1.5 pre-installed. To make sure you have the! latest version, select the!Software Update!item under the Apple menu. II the update! program determines that you need to upgrade!to the most recent version oI Java,! Iollow the instructions Ior doing so.! ! any trouble installing Eclipse, please email Ben Newman at II you run! into! a edu. [email protected] Irom the CS106A see zip http://technicalsupportindia.blogspot.com/ id8941171 pdfMachine by Broadgun Software - a great PDF writer! - a great PDF creator! - http://www.pdfmachine.com http://www.broadgun.com ! ! 2 ! Figure 2. Instructions for downIoading EcIipse on a Windows-based pIatform! Our version oI Eclipse will only run on the Windows 2000, XP, and Vista operating! systems. II you have Windows 98 or ME on your computer, you will need to do your! class work in one oI the public computer clusters. BeIore installing Eclipse, you will! Iirst need to have a copy oI the latest version oI the Java JRE (Java Runtime! Environment) installed on your computer. Note that Java version 1.6 is the latest! version oI Java, but Eclipse will run Iine under version 1.5. II you know you have! JRE version 1.5 or later on your computer, you can skip directly to Step 3 below. II! you don't know which version, iI any, oI the JRE you have, or want to upgrade to the! latest version, iust start at Step 1. We recommend most students at Step 1.!! ! 1.! Uninstall previous versions of the 1RE.! BeIore installing a new version oI the! JRE, we recommend that you remove any older copies that may be installed on! your system.! a. Open the control panel by clicking on!Start, then!Settings, then!ControI!PaneI! b. Then select!Add!or!Remove!Programs!(on XP) or!Programs and Features!(on Vista)! c. From the list oI programs you see, remove/uninstall any occurrences oI! Java/ J2SE!Runtime!Environment, Java!SDK, or!Java!Update. Note that the exact program! name may be slightly diIIerent or include a version number, but you generally! want to remove anything that includes the text:! Java/J2SE!Runtime!Environment,! Java!SDK, or!Java!Update. To remove a program, click on the program name to! highlight it and click the!Remove!button (XP) or the!UninstaII!button (Vista).! 2.! Get the 1RE from the CS106A website.! a.! You can obtain a copy oI the Java JRE version 1.6 Irom the CS106A website:! http://www.stanford.edu/class/cs106a. Click on the! Software! section! link and then click on the Java 1.6 JRE installer for the PC!link.! b. AIter clicking this link a prompt will appear to ask you whether you want to! run or save the Iile. Click!Run!to begin the download and installation process.! II a subsequent security warning dialog box appears, click! Run! (or Yes) to! continue with the installation.! c. The Java JRE installation program should begin. Do a!TypicaI!installation, and! Iollow the rest oI the instructions given in order to complete your installation.! 3.! Get Eclipse from the CS 106A website.!BeIore you begin to write your Iirst Java! or Karel program, you will need to obtain a copy oI Eclipse! Irom the CS 106A! course website. To do so, go to!http://www.stanford.edu/class/cs106a, click! on the!Software!section link and then click on!EcIipse!for!Windows!Vista!and!XP, and! save the Iile to somewhere on your hard drive. This may take a little while as the! Iile being downloaded is rather large.! 4.! Install Eclipse.!Unzip/extract the contents oI the Iile by right-clicking on the Iolder! you iust downloaded (which is named! stanford_ecIipse32_windows), selecting the Extract!AII...! option and typing! C:\Program Files\Eclipse! as the location to! extract the Iiles to. Then continue Iollowing the steps in the extraction process.! (Note: iI your version oI Windows does not have built-in support Ior! unzipping/extracting programs, you can obtain a program to unzip/extract Iiles at! http://www.winzip.com.)! 5.! Create a shortcut.! AIter extracting Eclipse, you can then create a shortcut Ior! easy access to the program.! a. Open the!C:\Program Files\Eclipse\eclipse!directory! b. Right-click and drag the!eclipse.exe!Iile to your desktop and then select the! option!Create!shortcut!here.! Irom the! CS! 106A http://technicalsupportindia.blogspot.com/ ! ! 3 ! Running Eclipse! At this point you should have Eclipse installed and working on your computer. When you! run eclipse Ior the Iirst time, you may get a screen that looks like this:! ! ! ! A workspace is iust a directory that Eclipse will use to place new proiects in. In 106A you! won`t have to make any new proiects Irom scratch. We will always give you skeleton! proiects Ior your assignments, so you don`t need to worry about where the workspace is.! The suggested location is Iine. Click the!Use!this!as!the!default!and!do!not!ask!again!checkbox,! and then click! OK. Once you do, Eclipse will start running andaIter what may seem! like a relatively long timebring up the Iollowing screen:! ! ! http://technicalsupportindia.blogspot.com/ ! ! 4 ! The layout oI the screenwhich the Eclipse designers decided to call a! perspective corresponds to the StanIord Editor perspective, which is where you will want to start! editing your programs. Because Eclipse is a proIessional tool, it contains many advanced! Ieatures that only get in the way in an introductory course. The purpose oI the StanIord! Editor perspective is to hide all the scary-looking Ieatures that you don`t need. II you ever! Iind yourselI in a perspective that seems conIusing, click on!Stanford!in the menu bar and! then select!Switch!to!Editor. You can also click on the!Switch!to!Editor!button Irom the main! toolbar, which looks like this:! ! ! ! Once you have Eclipse loaded, your next step will usually be to create a new proiect in! your workspace by importing a skeletal Iramework that we provide called a! starter! project.! Using starter proiects make your liIe much easier by allowing you to ignore the! many details involved in creating a proiect Irom scratch. Every assignment will include a! starter proiect Ior each problem, and your Iirst task will be to download the starter proiect! Irom the class website and then importing it into your workspace. The details Ior doing! so are described in the handout "Using Karel with Eclipse".! ! http://technicalsupportindia.blogspot.com/ Mehran Sahami Handout #8 CS 106A September 26, 2007 Submitting Work Based on a handout by Eric Roberts
This handout provides a little more background on submitting work. Remember first of all that each assignment requires two submissions: an electronic component submitted through Eclipse and a hardcopy component submitted in class. Whether an assignment is submitted on time is determined by the electronic submission, which is timestamped in the submission process. That time is based on the time on the server that receives the assignment, so it pays to submit things with a few minutes to spare, particularly if you should be submitted in class on the due date for the assignment, and must match the electronic submission. It is not appropriate, for example, to submit an uncommented rough draft early and then hand in a beautifully commented listing for your hardcopy.
6XEPLWWLQJWKHHOHFWURQLFFRPSRQHQW The Stanford version of Eclipse makes submission a relatively painless process. All you need to do is select the Submit Project entry under the Stanford menu, as you did for the Karel assignment:
Once you click on this button, Eclipse will bring up a dialog box asking you to select a project from your workspace, enter your SUNet ID and password, and then click on the Finish button.
In many cases and particularly here in the case of Assignment #1 the project file will contain the source files for all the problems, so that a single submission is sufficient to deliver all the files. You may, however, make new submissions by invoking the Submit Project mechanism additional times. Your section leader will receive only the most recent submission.
The project you submit must contain all the files necessary to run your program. These files will typically be .java files containing programs. However, particularly if you are extending the program (say, ++ score), you may also have some image files or audio clips that are part of the submission as well. http://technicalsupportindia.blogspot.com/ 2 6XEPLWWLQJWKHKDUGFRS\FRPSRQHQW The hardcopy submissions must include the following:
1. A listing of your program. Even though you will also submit an electronic version of your code, we require you to submit a listing of that program on paper. That listing must include all the code that you have written for the assignment, but need will note errors and stylistic issues on the hardcopy submission and return that to you at the interactive grading session. 2. When you submit the hardcopy part of your assignment, please be sure to include . ny people forget to do this. Not having these names makes it very hard for us to sort the assignments.
Program listings and sample runs are both easy to generate in Eclipse. All you need to do is select the Print command under the File menu.
0DNHDEDFNXSFRS\RI\RXUDVVLJQPHQW Although we work hard to keep track of all the assignments that come in, the fact that CS 106A has so many students and such a large staff means that assignments have sometimes gotten lost. If your assignment goes missing, you will need to resubmit. To make resubmission possible, you are responsible for keeping a backup copy.
http://technicalsupportindia.blogspot.com/ ! ! Part II-The REAL Assignment: Karel problems (due 3:15pm on Friday, Oct. 5th)! The real problem solving portion oI this assignment consists oI Iour Karel programs.! There are starter proiects Ior each oI these problems on!the CS 106 web site in the area! Ior Assignment 1. When you want to work on! one oI these programs, you need to! download that starter Iolder as described in Handout #6 (Using Karel in Eclipse). From! there, you need to edit the program! Iiles so that the assignment actually does what it`s! supposed to do, which will involve a cycle oI! coding, testing, and debugging until! everything works. The Iinal step is! to submit your assignment using the! ! ! entry under the! !menu. Remember that you can submit your programs individually! as you Iinish them and that you can submit! more than one version. II you discover an! error aIter you`ve submitted one oI these!problems, iust Iix your program and submit a! new copy.! Also, Please remember that your Karel programs must limit themselves! to the language features described in!/EVIPXLI6SFSX0IEVRW.EZE!in the!/EVIP! and! 7YTIV/EVIP! classes. You may not use other features of 1ava, even though the! Eclipse-based version of Karel accepts them.! ! The Iour Karel problems to solve are described below.! Mehran Sahami Handout #7! CS 106A September 26, 2007! Assignment #1: Email and Karel the Robot! Karel problems due: 3:15pm on Friday, October 5th! Email due: 11:59pm on Sunday, October 7th! Based on a handout by Eric Roberts! http://technicalsupportindia.blogspot.com/ ! 3 ! Problem 1! Your Iirst task is to solve a simple story-problem!in Karel`s world. Suppose that Karel! has settled into its house, which is the square area!in the center oI the Iollowing diagram:! ! 1 2 3 4 5 6 7 1 2 3 4 5 ! ! Karel starts oII in the northwest!corner oI its house as shown in the diagram. The problem! you need to get Karel to solve is to collect!the newspaperrepresented (as all obiects in! Karel`s world are) by a beeperIrom outside!the doorway and then to return to its initial! position.! ! This exercise is extremely simple and exists!iust to get you started. You can assume that! every part oI the world looks iust as it does!in the diagram. The house is exactly this size,! the door is always in the position shown, and the beeper is iust outside the door. Thus, all! you have to do is write the sequence oI commands necessary to have Karel! ! 1. Move to the newspaper,! 2. Pick it up, and! 3. Return to its starting point.! ! Even though the program is only a Iew lines, it! is still worth getting at least a little! practice in decomposition. In your solution, include a private method Ior each oI the! steps shown in the outline.! ! A Word of Advice! ! BeIore you go on to the harder problems on this assignment, why don`t! you try submitting your proiect as soon as you are done with this Iirst! problem? Every year, a handIul!oI students run into some kind oI problem! with the electronic submission option provided in the StanIord version oI! Eclipse. II you wait until 4:45P.M. on Friday beIore you submit any oI! your work, you may discover that there is some aspect oI the submission! process that you didn`t quite understand only!aIter it`s too late to get any! help. So right now, as soon as you`ve got this Iirst program working, go! ahead and hit the submit button to make!sure that you can ship things oII.! Once you`ve done so, you`ll know that you`ve got the submission process! under control. Remember, we only look!at the last submission you make! beIore the due date, so it doesn`t! hurt to submit new versions oI your! solution as you Iinish them.! http://technicalsupportindia.blogspot.com/ ! 4 ! Problem 2! Karel has been hired to repair the damage done to the Quad in the 1989 earthquake. In! particular, Karel is to repair a! set oI arches where some oI the stones (represented by! beepers, oI course) are missing Irom!the columns supporting the arches, as Iollows:! ! 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 5 6 7 8 ! Your program should work on!the world shown above, but it should be general enough to! handle any world that meets certain basic conditions as outlined at the end oI this! problem. There are several example worlds!in the starter Iolder, and!your program should! work correctly with all oI them.! ! When Karel is done, the missing stones in the columns should be replaced by beepers, so! that the Iinal picture resulting Irom the world shown above would look like this:! ! 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 5 6 7 8 ! ! Karel may count on the Iollowing Iacts!about the world, list on the next page:! http://technicalsupportindia.blogspot.com/ ! 5 ! Karel starts at 1st Avenue and 1st Street, Iacing east, with! an inIinite number oI! beepers.! The columns are exactly Iour units!apart, on 1st, 5th, 9th Avenue, and so Iorth.! The end oI the columns is!marked by a wall immediately!aIter the Iinal column. This! wall section appears aIter 13th Avenue in the example,!but your program should work! Ior any number oI columns.! The top oI the column is marked by a wall, but Karel cannot assume that columns are! always Iive units high, or even!that all columns are the same height.! Some oI the corners in the column may already contain beepers representing stones! that are still in place. Your program should not!put a second beeper on these corners.! ! Problem 3! In this exercise, your iob is to get Karel to create a checkerboard pattern oI beepers inside! an empty rectangular world, as illustrated in!the Iollowing beIore-and-aIter diagram:! 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 ! This problem has a nice decomposition structure along with some interesting algorithmic! issues. As you think about how you will solve the problem, you should make sure that! your solution works with checkerboards that are diIIerent in size Irom the standard 8 8! checkerboard shown in the example. Odd-sized!checkerboards are tricky, and you should! make sure that your program generates the Iollowing pattern in a 5 3 world:! ! 1 2 3 1 2 3 4 5 ! ! Another special case you need to consider is!that oI a world which is only one column! wide or one row high.! The starter Iolder contains several sample worlds that test these! special cases, and you should!make sure that your program!works Ior each oI them.! http://technicalsupportindia.blogspot.com/ ! 6 ! Problem 4! As an exercise in solving algorithmic problems,!program Karel to place a single beeper at! the center oI 1st Street. For example, iI Karel starts in the world! ! 1 2 3 4 5 1 2 3 4 5 ! ! it should end with Karel standing on a beeper in the Iollowing position:! ! 1 2 3 4 5 1 2 3 4 5 ! ! Note that the Iinal conIiguration! oI the world should have only a single beeper at the! midpoint oI 1st Street. Along the way, Karel is allowed to place additional beepers! wherever it wants to, but must pick them!all up again beIore it Iinishes.! ! In solving this problem, you may count on!the Iollowing Iacts about the world:! ! Karel starts at 1st Avenue and 1st Street, Iacing east, with! an inIinite number oI! beepers in its bag.! The initial state oI the world includes no interior walls or beepers.! The world need not be square, but you may assume!that it is at least as tall as it is wide.! ! Your program, moreover, can assume the Iollowing simpliIications:! ! II the width oI the world is odd, Karel must!put the beeper in the center square. II the! width is even, Karel may drop the beeper on either oI the two center squares.! It does not matter which direction Karel!is Iacing at the end oI the run.! ! There are many diIIerent algorithms you! can use to solve this problem. The interesting! part oI this assignment is to come up with a strategy that works.! http://technicalsupportindia.blogspot.com/ Mehran Sahami Handout #6! CS 106A September 26, 2007! Using Karel with Eclipse! Based on a handout by Eric Roberts! ! Once you have downloaded a copy oI Eclipse as described in Handout #5, your next task! is to understand how to write Karel programs!using the Eclipse Iramework. Although it is! not all that hard to create new! Eclipse proiects Irom scratch,! it certainly reduces the! complexity oI assignments iI we!provide starter proiects to get!you going. That way, you! can ignore all the mechanical details oI! making new proiects and Iocus instead on the! problem-solving aspects oI the assignments.! ! Downloading starter projects! The Iirst step in working with any Karel assignment is to download the starter proiect Ior! that assignment. II you go to the CS106A assignment page (go to the CS106A web site! and click the!Assignments!link), you`ll see a display!that looks like something this:! ! ! ! II you click on the link Ior! Assignment1.zip, your web browser will download the! starter Iolder. In some cases,!the browser will also unzip/extract the Iolder automatically,! assuming that you have the!appropriate soItware Ior expanding Iiles Irom a ZIP archive.! The notes on the assignment page!above tell you what soItware you need. The unzipped! contents oI the ZIP Iile is!a directory named!Assignment1!that contains the proiect. Move! that Iolder to someplace on your Iile system where you! can keep track oI it when you! want to load the proiect.! ! Importing projects into the workspace! From here, your next step is to start up!Eclipse, which will bring up the Eclipse window! shown on the last page oI Handout #5. Find the small icon in the toolbar that looks like:! ! http://technicalsupportindia.blogspot.com/ ! 2 ! This button is the! ! !button and is used to copy a!proiect Iolder into the Eclipse! workspace so that you can work with it.! Click on this button and then use the! ! option to Iind the! Assignment1! Iolder. When you do so,! Eclipse will load the starter! proiect and display its name in the! ! !window like this:! ! ! ! The small triangle to the leIt oI!the Iolder name indicates that you can open it to reveal its! contents. When you click on the triangle, it exposes the Iirst level oI the package:! ! ! ! Note that you likely may not!see the "JRE System Library" line displayed in the graphic! above (or iI you do, it may have a diIIerent number like 1.5 or 1.6, rather than 1.4.2).! Nevertheless, at this point things look a more!promising there is something about Karel! there on the last line. But things get more interesting when you open the deIault package,! which is where the code you will!write this quarter will go. Opening this package reveals! ! ! http://technicalsupportindia.blogspot.com/ ! 3 ! ! Now things have gotten much more exciting. Thereright on the screenare the Java! Iiles Ior each oI the assignments. You can open!any oI these Iiles by double-clicking on! its name. II you double-click on! CollectNewspaperKarel, Ior! example, you will see the! Iollowing Iile appear in the editing area in!the upper right section oI the Eclipse screen:! ! ! ! Note that the comments at the top!oI the Iile many not display initially and may need to! be "expanded" by clicking the small '+' sign next to the comment header line.! ! As you might have expected, the Iile we!included in the starter!proiect doesn`t contain the! Iinished product but only the header line Ior the!class. The actual program must still be! written. II you look at the assignment handout, you`ll see that the problem is to get Karel! to collect the 'newspaper Irom outside the!door oI its 'house as shown in this diagram:! ! 1 2 3 4 5 6 7 1 2 3 4 5 ! Suppose that you iust start typing away and create a! run! method with the steps on the! Iollowing page:! ! http://technicalsupportindia.blogspot.com/ ! 4 ! public void run() {! ! move();! ! turnRight();! ! move();! ! turnLeft()! ! move();! ! pickBeeper();! }! ! ! The bug symbol oII to the side lets you know that this program isn`t going to do exactly! what you want, but it is still interesting! to see what happens.! Eclipse compiles your! program Iile every time you save! it and then tells you abut any errors it Iound. In this! case, saving the Iile generates the Iollowing inIormation in the two right-hand windows:! ! ! ! ! ! The! ! screen shows the error messages, which are also highlighted with the! ! symbol in the editor window. Here, the error message is extremely clear: there is a! missing semicolon at the end oI the indicated line. This type oI error is called a! syntax! error!because you have done something that violates the syntactic rules oI Java. Syntax! errors are easy to discover because Eclipse!Iinds them Ior you. You can then go back, add! the missing semicolon, and save the Iile again. This time, the! !screen shows:! ! http://technicalsupportindia.blogspot.com/ ! 5 ! ! ! Even though part oI the error message is cut oII, the reason Ior the problem is clear! enough. The Karel class understands!turnLeft!as a command, but not!turnRight. Here! you have two choices to Iix the problem. You can either go back and add the code Ior! turnRight!or change the header so that!CollectNewspaperKarel!extends!SuperKarel! instead. Fixing this problem leads to a! successIul compilation in which no errors are! reported in the! !screen.! ! Even though the program is not Iinishedboth because it Iails to return Karel to its! starting position and because it doesn`t decompose the problem to match the solution! outline given in the assignmentit may still!make sense to run it and make sure that it! can at least pick up the newspaper.! ! Running a Karel program under Eclipse! Running a program under Eclipse makes!use oI the two buttons on the tool bar that look! like this:! ! ! ! The button on the leIt causes Eclipse to search the workspace Ior all runnable programs! and ask you which one you want to run.! Since all Iour programs Irom Assignment 1 are! part oI the workspace, clicking this button will!generate a list containing the names oI the! Iour Karel classes. The button on the right is a 'Iaster version oI the run button that! skips the search Ior runnable programs and! iust runs the same program you ran most! recently during this Eclipse session.! ! II you then select! CollectNewspaperKarel! Irom the list oI programs that appears,! Eclipse will start the Karel! simulator and, aIter several seconds, display a window that! looks like the picture on the next page:! ! http://technicalsupportindia.blogspot.com/ ! 6 ! ! ! II you then press the! ! ! button, Karel will go through the steps in the! run! method you supplied.! ! In this case, however, all is not well.!!Karel begins to move across and down the window! as iI trying to exit Irom the house, but ends up!one step short oI the beeper. When Karel! then executes the!pickBeeper!command at the end oI the!run!method, there is no beeper! to collect. As a result, Karel stops and displays an error dialog that looks like this:! ! ! ! This is an example oI a!logic error,!which is one in which you!have correctly Iollowed! the syntactic rules oI the language but nonetheless have written a!program that does not! correctly solve the problem. Unlike syntax errors, the compiler oIIers relatively little help! Ior logic errors. The program you`ve written is perIectly legal. It iust doesn`t do the right! thing.! ! Debugging! 'As soon as we startea programming. we founa to our surprise that it wasnt as! easv to get programs right as we haa!thought. Debugging haa to be aiscoverea.! I can remember the exact instant when I realizea that a large part of mv life! from then on was going to be spent in!finaing mistakes in!mv own programs.`! Maurice Wilkes, 1979! ! http://technicalsupportindia.blogspot.com/ ! 7 ! More oIten than not, the programs that you write will not work exactly as you planned! and will instead act in some mysterious way. In all likelihood, the program is doing! precisely what you told it to. The problem is that what you told it to do wasn`t correct.! Programs that Iail to give correct results because oI some logical Iailure on the part oI the! programmer are said to have! bugs;! the process oI getting! rid oI those bugs is called! debugging.! ! Debugging is a skill that comes only with practice. Even so, it is never too early to! learn the most important rule about debugging:! ! In trving to fina a program bug. it is far more important to! unaerstana what vour program is!aoing than to unaerstana what it! isnt!aoing.! ! Most people who come upon a problem in their code!go back to the original problem and! try to Iigure out why their program isn`t doing what they wanted. Such an approach can! be helpIul in some cases, but it is more likely that this kind oI thinking will make you! blind to the real problem. II you make an!unwarranted assumption!the Iirst time around,! you may make it again, and be leIt in the position that you can`t Ior the liIe oI you see! why your program isn`t doing the right thing.! ! When you reach this point, it oIten helps to!try a diIIerent approach. Your program is! doing!something. Forget entirely Ior the moment what it was supposed to be doing, and! Iigure out exactly what is happening. Figuring out what a wayward program is doing! tends to be a relatively easy task, mostly because you have the computer right there in! Iront oI you. Eclipse has many tools! that help you monitor the execution oI your! program, which makes it much easier to Iigure out what is going on. You`ll have a! chance to learn more about these Iacilities in the coming weeks.! ! Creating new worlds! The one other thing you might want to! know about is how to create new worlds. The! three buttons on Karel`s control panel! ! ! ! Do pretty much what you`d expect. The! ! !button brings up a dialog that allows! you to select an existing world Irom the Iile system,! ! !allows you to create a new! world and to speciIy its size, and! ! ! gives you a chance to change the! conIiguration oI the current world.! ! When you click on the! ! !button, the control panel changes to present a tool menu! that looks like the picture on the next page:! ! http://technicalsupportindia.blogspot.com/ ! 8 ! ! ! This menu oI tools gives you everything you!need to create a new world. The tools! ! ! ! allow you to create and remove walls. The dark square shows that the! ! !tool is! currently selected. II you go to the map and click on the spaces between corners, walls! will be created in those spaces. II you later!need to remove those walls, you can click on! the! ! !tool and then go back to the map to eliminate the unwanted walls.! ! The Iive beeper tools! ! ! ! allow you to change the conIiguration oI beepers on any oI the corners. II you select the! appropriate beeper tool and then click on a corner, you change the number oI beepers! stored there. II you select!one oI these tools and then click on the beeper-bag icon in the! tool area, you can adiust the number oI beepers in Karel`s bag.! ! II you need to move Karel to a new starting position, click on Karel and drag it to some! new location in the map. You can change Karel`s orientation by clicking on one oI the! Iour Karel direction icons in the tool area. II!you want to put beepers down on the corner! where Karel is standing, you have to Iirst move! Karel to a diIIerent corner, adiust the! beeper count, and then move Karel back.! ! These tools should be suIIicient Ior you to create any world you`d like, up to the! maximum world size oI 50 50. Enioy!! ! http://technicalsupportindia.blogspot.com/