Presentation is loading. Please wait.

Presentation is loading. Please wait.

15-100: Introduction to Programming w/ Java * Ananda Gunawardena -- Lecture – School of Computer Science – Phone : 268-1559 (x81559) – Office: Wean Hall.

Similar presentations


Presentation on theme: "15-100: Introduction to Programming w/ Java * Ananda Gunawardena -- Lecture – School of Computer Science – Phone : 268-1559 (x81559) – Office: Wean Hall."— Presentation transcript:

1 15-100: Introduction to Programming w/ Java * Ananda Gunawardena -- Lecture – School of Computer Science – Phone : 268-1559 (x81559) – Office: Wean Hall 5113 – guna@andrew.cmu.edu Teaching Assistants – Lab Help, Grading – Helen Han ( shanshan@andrew.cmu.edu ) * Modified from Original Lectures by Don Slater

2 15-100 Java – variables, conditionals, loops, arrays – object oriented programming Problem solving skills Time management skills

3 How to be Successful in this course Attend class Do the homework – they are designed to help you digest the chapter Do the labs (programming assignments) – they are designed to help you learn how to use the concepts covered in the chapter and discussed during lecture – start the labs early, programming assignments ALWAYS take longer than you think they will The material in each session builds on the material from the previous session

4 Course Web Site http://www.andrew.cmu.edu/~guna/15-100 All important information about the course is posted at this site… Check it for What is New Syllabus and course policies are posted here… Syllabus Contact information is posted here… Home Assignment information is posted here… Assignments (where you will find links to labs and homework Course materials (lectures and demo code) will be found here… lectures and demos Course Labs can be found … labs Assessment information can be found assessment

5 Karel the Robot A Java-based language, with a graphical interface, used as a “first-pass” introduction to the concepts we will study in this course We will learn how to write instruction- sets (programs) so that our programmable robots can perform the tasks we give them

6 A Robot in its World Beeper Robot Wall Avenue Street Corner Origin 1 st St., 1 st Ave. N

7 The Robot World A great, flat, plane with standard compass points – Bounded on west by infinite wall extending north – Bounded on south by infinite wall extending east Crisscrossing the world are vertical streets and horizontal avenues – A corner is an intersection of a street and avenue – One or more robots can occupy any corner, facing any direction – Both streets and avenues have numbers – Origin is where 1 st St and 1 st Ave intersect – Robots do not have to start from origin

8 Objects in the Robot World Wall Sections – Positioned between adjacent street corners, blocking a robot’s direct path – Used to represent obstacles around which robots must navigate Beepers – Small plastic cones that emit a quiet beeping noise – Found on street corners; do not interfere with robot movement – Can be carried, picked up and put down by robots – There can be more than one beeper on a corner, and a robot can carry an infinite supply of beepers – Used to represent tasks for the robots to manipulate

9 Robot Capabilities Robots can move – Forward in the direction it is facing,from corner to corner – Turn in place – Turn itself off Robots can detect – Walls ½ block in front of them – Beepers by being on the same corner as a beeper – Robots on the same corner with it Robots can navigate by detecting the direction it is facing (north, south, east, west) Robots can manipulate beepers – by carrying them, – picking them up, and putting them down, – knowing if it is carrying any

10 Working with Robots Robots come from the main factory, Karel-Werke – Can supply several different models of robots – We can work with standard model, or provide specifications for a specialized robot When we want a robot to accomplish a task – Describe special features of the robot we want – Provide instructions on how to perform the task The tasks are written in a robot programming language, with its own vocabulary, punctuation marks and grammar

11 Robot Tasks A task is something we want the robot to do – Escape from an enclosed room that has a door – Find a beeper and deposit it on origin – Escape from a maze A situation is an exact description of what the world looks like – Robot’s current position and direction it is facing? – Location and length of each wall section? – Location of each beeper? – How many beepers in the robots beeper bag? Most situations will be specified by a map or a brief written description

12 Primitive Instructions Changing position – move: moves forward to next corner if the path is clear error-shutoff if the path is blocked by a wall – turnLeft: pivots 90 degrees to the left (counter-clockwise) stays on the same corner – turnOff: the task is finished; robot turns off and is incapable of executing any new instructions until restarted on another task

13 Primitive Instructions Manipulating beepers – pickBeeper: attempts to pick up beeper on the corner it is standing an error shutoff if no beeper is there if more than one beeper on the corner the robot picks up only one – putBeeper: attempts to put beeper on the corner it is standing an error shutoff if no beeper in the beeper bag if more than one beeper in the beeper bag the robot puts down only one

14 A Robot Program – Karel First Figure 2.3 See Fig 2.3 Demo Project

15 Robot Language Grammar Special symbols – Semi-colon ; at the ending of each robot instruction – Braces { } to group sets or blocks of robot instructions – Period. To show which instructions belong to which robot Identifiers – For robot and class names Reserved words – Used to structure and organize primitive instructions Comments – // single line comments; /* */ multi line comments – Provide explanation of what is going on to other people who read our programs

16 Programming Errors Execution Errors / Error Shutoffs – Illegal move, putBeeper, or pickBeeper instructions – Also if there is no turnOff at the end of a program – Figure 2.1 Figure 2.1 – See Figure 2.1 Demo Project See Figure 2.1 Demo Project Lexical errors – When a robot encounters an instruction that is not part of its vocabulary mvoe() instead of move(); turnleft() instead of turnLeft() Yes, capitalization counts; the programming language is case sensitive

17 Programming Errors Syntax errors – Use of incorrect grammar or punctuation A robot instruction missing a semi-colon at the end Intent error – Program seems to run successfully, but does not accomplish the task Task: pickup the beeper, face north, move one block The robot picks up the beeper, and moves ahead two blocks

18 A task for Two Robots Figure 2.5 See Figure 2.5 Demo Project


Download ppt "15-100: Introduction to Programming w/ Java * Ananda Gunawardena -- Lecture – School of Computer Science – Phone : 268-1559 (x81559) – Office: Wean Hall."

Similar presentations


Ads by Google