1 / 11

Introduction to Computer Programming

This lecture covers instance variables, conditionals, and assignments in computer programming. Topics include class layout, instance variables, conditional statements, and an introduction to the coding style. Relevant code examples and resources are provided.

dpotter
Download Presentation

Introduction to Computer Programming

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. 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.html#instance • Pay attention to the coding style!

  6. Variables • Def: A symbol which can hold a value of a particular type <dataType> <name>; int count;

  7. Instance/Data Variables • How do we create an instance variable? <dataType> <name>; 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.html#instance

  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

More Related