1 / 36

BIT 115

BIT 115. Introduction to Programming: Java Learning to Program Robotically. INSTRUCTOR : Craig Duckett EMAIL : cduckett@cascadia.edu. What is Computer Programming?. Computers don't do anything without someone telling them what to do—much like the average middle school student.

phiala
Download Presentation

BIT 115

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BIT 115 Introduction to Programming: Java Learning to Program Robotically INSTRUCTOR: Craig Duckett EMAIL: cduckett@cascadia.edu

  2. What is Computer Programming? • Computers don't do anything without someone telling them what to do—much like the average middle school student. • To make the computer do something useful, you must give it instructions in either of the following two ways: • Write a program that tells a computer what to do—step by step—much as you write out a recipe. • Buy a program that someone else has already written that tells the computer what to do. • Ultimately, to get a computer to do something useful, you (or somebody else) must write a program. • A program does nothing more than tell the computer how to accept some type of input, manipulate that input, and spit it back out again in some form that humans find useful.

  3. Programming is Problem-Solving • Essentially, a program tells the computer how to solve a specific problem. Because the world is full of problems, the number and variety of programs that people can write for computers is practically endless. • But to tell a computer how to solve one big problem, you usually must tell the computer how to solve a bunch of little problems that make up the bigger problem. If you want to make your own video game, for example, you need to solve some of the following problems: • Determine how far to move a figure (such as a car, a spaceship, or a man) on-screen as. • Detect whether the figure bumps into a wall, falls off a cliff, or runs into another figure on-screen. • Make sure that the figure doesn't make illegal moves, such as walking through a wall. • Draw the terrain surrounding the cartoon and make sure that if the figure walks behind an object such as a tree, the tree realistically blocks the figure from sight. • Determine whether bullets that another figure fires are hitting the player's figure. If so, determine the amount of damage, how it affects the movement of the damaged figure, and how the damage appears on-screen. • The simpler the problem is that you need to solve, the more easily you can write a program that tells the computer how to work. A program that displays a simple Ping-Pong game is much easier to write than a program that displays World War II fighter airplanes firing machine guns and dropping bombs on moving tanks while dodging anti-aircraft fire in a smoke-filled sky.

  4. Programming isn’t Difficult, but Time-Consuming • Programming really isn't that difficult or mysterious. If you can write step-by-step instructions directing someone to your house, you can write a program. • The hardest part about programming is identifying all the little problemsthat make up the big problem that you're trying to solve. Because computers are completely mindless, you need to tell them how to do everythingand also how to continue when something unexpected happens. This means thinking through many “what if” scenarios. • Like Philosophers and other wooly thinkers, Programmers are constantly questioning and considering all the various ifs, ands, and buts of logic and decision-making. “What if…?”

  5. Philosophers & Programmers What do they have in common besides pondering and logic? Everybody else in the world Philosophers | Programmers

  6. Still … Even though most of us practice philosophical thinking and the components of logic and decision-making hundreds of times a day … … we just don’t do it for a living or make a career out of it. And why? Most people are not “cut out” to be philosophers or programmers. Most people don’t “get” whatever it is that philosophers and programmers “get” and it is for this reason, most people are not philosophers or programmers. Philosophers and programmers are a rare and often solitary breed. Now, going on, let’s consider Logic & Decision-Making …

  7. A Simple Scenario… The Task: Directions 1. Go from Point A to Point B

  8. …Where Things CouldGo Wrong … The Task: 1. Go from Point A to Point B 2. Watch for passing cars at the Intersections OR 3. Treat Intersections as 4-Way Stops

  9. Decisions, Decisions … The Task: 1. Go from Point A to Point B 2. Stop at all Intersections (2-way stops going North and South) 3. Watch for cars going West and East before going through the Intersections.

  10. Different Decisions NOT Based on Directions… The Task: 1. Go from Point A to Point B 2. Treat Intersections as 4-Way Stops 3. Consider rules of “Right of Way” before going through the Intersection a) Car to left b) Car to right c) Car ahead, not turning d) Car ahead, turning 4. Unexpected things: IF / ELSE / OR / AND

  11. More Decisions … The Task: 1. Go from Point A to Point B 2. Treat Intersections as 4-Way Stops 3. Consider rules of “Right of Way” before going through the Intersection a) Car to left b) Car to right c) Car ahead, not turning d) Car ahead, turning 4. Unexpected things: IF / ELSE / OR / AND

  12. Alternative Decisions … The Task: 1. Go from Point A to Point B 2. Treat Intersections as 4-Way Stops 3. Consider rules of “Right of Way” before going through the Intersection a) Car to left b) Car to right c) Car ahead, not turning d) Car ahead, turning 4. Unexpected things: IF / ELSE / OR / AND

  13. Different Decisions … The Task: 1. Go from Point A to Point B 2. Consider rules of “Green / Red / Yellow ” before going through the Intersection a) Red - STOP b) Green - GO c) Yellow - CAUTION 3. Unexpected things: IF / ELSE / OR / AND

  14. Unexpected Decisions … The Task: 1. Go from Point A to Point B 2. Consider rules of “Green / Red / Yellow ” before going through the Intersection a) Red - STOP b) Green - GO c) Yellow - CAUTION 3. Unexpected things: IF / ELSE / OR / AND Tree Across Roadway Power Lines Across Roadway Gravel in Roadway Glass/Metal in Roadway

  15. Different Decisions … The Task: 1. Go from Point A to Point B 2. Consider rules of “Green / Red / Yellow ” before going through the Intersection a) Red - STOP b) Green - GO c) Yellow - CAUTION 4. Unexpected things: IF / ELSE / OR / AND

  16. Programming is All About Decision Making, Logic, & Memory Do … While If … Then Or … Else And … Or True … False … Fail Gracefullyand Meaningfully All this DECISION MAKINGhas to be STORED and TRACKED somewhere!

  17. …And Avoiding Errors/Crashes/Blue Screens

  18. But How Does It All Work? • Central Processor Unit (CPU) • Memory • Storage • Input/Output (I/O) • Keyboard • Mouse • Monitor • Speakers • Network

  19. Memory • RAM (Random Access Memory) • DRAM (Dynamic)

  20. Memory Storage Cells"Allocated Memory Locations" http://static.howstuffworks.com/flash/ram-virtual.swf

  21. Memory  Text Characters ASCII (American Standard Code for Information Interchange) Play Video

  22. Java  Memory Throughout the quarter, instead of calling these by their correct name, Allocated Memory Locations, I will usually just called them "Buckets".

  23. Programming Paradigms • Procedural (Top Down “Function” Driven) • Object Oriented(“Class” and “Object” Driven)

  24. Procedural Programming Programs in the past used a procedural process for development where a program performed in series of steps , in a linear fashion  and the focus was  on steps as shown below:

  25. Object-Oriented Programming In object-oriented programming, the focus is on real world objects which interact with each other. Objects in turn have state, attributesand operations. Objects are viable things that do something. Objects perform actions.

  26. Class , Objects, and Methods:Here Comes the Hippy-Dippy Stuff!

  27. Class: Example Using Language “Dog” • Animal • Mammal • Breed • Fur • Barks • Plays fetch • Digs • Chase cats • Eats • Sleeps • Etc. …

  28. Class: Example Using Language Animal The word "animal" comes from the Latin word animalis, meaning "having breath". The biological definition of the word refers to all members of the kingdom Animalia, encompassing creatures as diverse as fish, reptiles, birds, mammals, and insects . Mammals are air-breathing vertebrate animals characterized by the possession of endothermy, hair, three middle ear bones, and mammary glands functional in mothers with young. Mammal • Animal • Mammal • Breed • Fur • Barks • Plays fetch • Digs • etc … “Dog”

  29. From Consensus  Class  Object “Dog”

  30. We think in terms of “Class” all the time … For instance, do you understand this sentence? The dog chased the ball into the street and nearly got hit by the car. Okay, if you understand this sentence, then … • What kind of dog was it? • What kind of ball was it? • What kind of street was it? • What kind of car was it?

  31. “Class”  Objects “Dog” “Ball” “Street” “Car” General Attributes General Attributes General Attributes General Attributes Specific Properties and Actions Specific Properties and Actions Specific Properties and Actions Specific Properties and Actions

  32. Class  Object In Object-Oriented Programming, a Classis like a cookie cutter and dough, and Objectsare like the unique cookies made from them

  33. Class  Class  Object PersonWithCapAndBag EXTENDS Person In Java, the various things (actions) that Objects do are called Methods

  34. Dot Notation Mailman.fillBag(); Mailman.deliverMail(); Mailman.pickUpMail(); Mailman.putMailInBag(); Mailman.runFromBigDog(); Paperboy.fillBag(); Paperboy.deliverPaper(); Paperboy.runFromBigDog(); Paperboy.drinksSlurpee(); Paperboy.collectsPayment(); Object Method Object Method

  35. What you will learn in this Introduction to Programming class is just the "tip of the iceberg" but it will establish a firm foundation for you to confidently go on to learn and excel in other programming languages.

More Related