Introduction to Computer Programming - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Computer Programming

Description:

Introduction to Computer Programming CS 126 Lecture 6 Zeke Maier Plan for Today Questions Administrivia Quiz Instance Variables Conditionals Assignment Questions ... – PowerPoint PPT presentation

Number of Views:123
Avg rating:3.0/5.0
Slides: 12
Provided by: ejm3
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Computer Programming


1
Introduction to Computer Programming
  • CS 126
  • Lecture 6
  • Zeke Maier

2
Plan for Today
  • Questions
  • Administrivia
  • Quiz
  • Instance Variables
  • Conditionals
  • Assignment

3
Questions
4
Administrivia
  • http//students.cec.wustl.edu/ejm3/
  • Lab assignment due Wednesday

5
Method Example Code
  • http//students.cec.wustl.edu/ejm3/CS126/web/code
    .htmlinstance
  • Pay attention to the coding style!

6
Variables
  • Def A symbol which can hold a value of a
    particular type
  • ltdataTypegt ltnamegt int count

Variable Instance Variable
Defined within a method Defined within a class
Can only be accessed within its method Can be accessed anywhere in the class
Used as a temporary holder of intermediate values Used to hold values describing the class
7
Instance/Data Variables
  • How do we create an instance variable?

ltdataTypegt ltnamegt int count
  • Which variable is the instance variable?

class Student String name public static void
main(String args) void printName()
String fullName Mr./Ms.
name System.out.println(Name name)
8
Class Layout
  • A Class is a blueprint for an object
  • It models something
  • Class consists of
  • Instance/Data Variables
  • Describe
  • Methods
  • Perform Actions

9
Instance Example Code
  • http//students.cec.wustl.edu/ejm3/CS126/web/code
    .htmlinstance

10
Conditional Statements
  • Allows us to change the behavior of the program
    based on certain conditions
  • Example absolute value

If (condition) //Statements to execute if the
condition is true
else //Statements to execute if the condition
is false
11
Assignment
  • Lab 1 due Wednesday in Lab
  • Readings
  • Wednesday
  • AD Chapter 4 4.1 - 4.7
  • KG Notes
Write a Comment
User Comments (0)
About PowerShow.com