cse 113 introduction to computer programming
Download
Skip this Video
Download Presentation
CSE 113 Introduction to Computer Programming

Loading in 2 Seconds...

play fullscreen
1 / 22

CSE 113 Introduction to Computer Programming - PowerPoint PPT Presentation


  • 98 Views
  • Uploaded on

CSE 113 Introduction to Computer Programming. Lecture slides for Week 2. Wednesday, September 7 th , 2011 Instructor: Scott Settembre. Section 1. Recitations (Labs). Labs Begin This Week. Go to Bell hall [next to Student Union] Room 340.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CSE 113 Introduction to Computer Programming' - oihane


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cse 113 introduction to computer programming

CSE 113Introduction toComputer Programming

Lecture slides for Week 2

Wednesday, September 7th, 2011

Instructor: Scott Settembre

recitations labs
Section 1Recitations (Labs)

University at Buffalo: CSE 113 Instructor: Scott Settembre

labs begin this week
Labs Begin This Week
  • Go to Bell hall [next to Student Union] Room 340.
    • There is key card access that your card won’t open, so you will need to wait for the TA sometimes to show up to let you in.
    • If you queue in the hall, please be respectful of the offices and classrooms around you.
  • Please go to your lab.
    • It is mandatory.
    • Attendance counts towards your grade.
    • There is an end of class assessement/quiz.

University at Buffalo: CSE 113 Instructor: Scott Settembre

what do i do in lab
What do I do in lab?
  • You will be doing the chapters from the Greenfoot book, step by step.
  • Do each exercise.
    • You do not need to record your answers.
    • The assessment/quiz at the end of the class may require you to answer some questions about those exercises.

University at Buffalo: CSE 113 Instructor: Scott Settembre

when i am done what do i do
When I am done, what do I do?
  • After you go through the chapters that you need to cover, you will:
    • Work on your project.
    • Take the assessment/quiz at the end of class.

University at Buffalo: CSE 113 Instructor: Scott Settembre

can t i take the quiz and leave
Can’t I take the quiz and leave?
  • No.
  • Use the two hours to experiment and work on your project.
    • If you at some point become done with your project, then work on it more.
    • Think of your project as an art piece, Leonardo da Vinci said that “art is never finished, only abandoned.”
    • When your project is due, that is when you are done! 

University at Buffalo: CSE 113 Instructor: Scott Settembre

for the first week in recitaiton
For the First Week in Recitaiton
  • For the week of September 7th
    • Please read chapter 1 and chapter 1 exercises.
    • Please read chapter 2 and chapter 2 exercises.
    • Please finish by taking the assessment/quiz.
    • At that point, for this week only, you can leave early!
  • The first project will be assigned next week.

University at Buffalo: CSE 113 Instructor: Scott Settembre

greenfoot interface
Section 2Greenfoot – Interface

University at Buffalo: CSE 113 Instructor: Scott Settembre

demonstration
Demonstration
  • You will become more familiar with the interface when you go hands-on with the book in the lab.
  • I will demo the interface here to show you around.

University at Buffalo: CSE 113 Instructor: Scott Settembre

greenfoot chapter 2
Section 3Greenfoot – Chapter 2

University at Buffalo: CSE 113 Instructor: Scott Settembre

chapter 2
Chapter 2
  • In this chapter you will learn:
    • How to start writing code.
    • How to find out what methods you can use.
    • What an “if”-statement is! (Probably the most important control statement you will learn.)

University at Buffalo: CSE 113 Instructor: Scott Settembre

what is inheritance
What is “inheritance”?
  • It is the “is-a” relationship between classes
  • For example:
    • “A dog is-a mammal”
    • “A chiuaua is-a dog”
  • This means that a dog “inherits” all the features that a mammal may have.
  • “Sub-classes” (see last weeks notes) inherit their properties and methods from their “Super-classes”

University at Buffalo: CSE 113 Instructor: Scott Settembre

crab and animal classes
Crab and Animal classes
  • Notice the arrow direction in the Actor classes tree.
    • A crab is-a animal.
    • An animal is-an actor.
    • Thus a crab is-a actor too!

University at Buffalo: CSE 113 Instructor: Scott Settembre

classes can inherit methods
Classes can inherit methods
  • The animal class has a method called “act”, so that means that the crab class will also have that method.

University at Buffalo: CSE 113 Instructor: Scott Settembre

what do the methods do
What do the methods do?
  • There are many methods in the animal class:
    • “act” method, does nothing.
    • “move” method, moves the actor in a forward direction.
    • “turn” method, rotates the actor a number of degrees specified in the parameter.
    • “atWorldEdge” method, returns a boolean value indicating if the actor is at the edge of the world.
  • What we will do is make the “act” method do something, like call the “move” method.

University at Buffalo: CSE 113 Instructor: Scott Settembre

writing code
Writing code
  • To begin writing code, let Greenfoot do the framework for you.
    • Double-click on the class to get the editor.
    • Go to the already formed “act” signature.
    • We can add “move();” within the brackets { } to make it move.

University at Buffalo: CSE 113 Instructor: Scott Settembre

note brackets and semicolons
Note: brackets and semicolons
  • You need to adhere to a specific “syntax”.
  • When you write English, we need to use “,” and “.” appropriately otherwise the reader will misread what you have written.
  • It is the same thing with Java, you need to use the “{“, “}” and “;” correctly or it will not understand you.

University at Buffalo: CSE 113 Instructor: Scott Settembre

semicolons
Semicolons
  • A semicolon “;” indicates an end of a command.
  • It is similar to a “.” at the end of an English sentence.

University at Buffalo: CSE 113 Instructor: Scott Settembre

brackets and code blocks
Brackets and code blocks
  • The instructions between a set of brackets is called a “code block” or the “body” of a method.
  • You must match each “{“ with a “}”

University at Buffalo: CSE 113 Instructor: Scott Settembre

syntax errors ooops i messed up
Syntax errors: Ooops, I messed up?!
  • This will happen a lot.
  • Greenfoot with alert you to a mistake.
  • You can see if you have any syntax mistakes by compiling or running your code.
  • Note: Sometimes you will have two or more mistakes, causing your code to compile/run, but not work properly. This is not a syntax error, this is a code error.

University at Buffalo: CSE 113 Instructor: Scott Settembre

to be continued on friday
To be continued on Friday

University at Buffalo: CSE 113 Instructor: Scott Settembre

ad