Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Programming

Similar presentations


Presentation on theme: "Introduction to Computer Programming"— Presentation transcript:

1 Introduction to Computer Programming
CS 126 Lecture 5 Zeke Maier

2 Plan for Today Questions Administrivia Lab Questions Review
Methods & Instance Variables Assignment

3 Questions lists – 13 million addresses turned over to the democratic party Blackberry – addicted – probably going to need to get rid of it – Presidential Records Act – Security of being able to constantly track where the president was? Youtube radio broadcasts, constantly updating website, twitter, whitehouse.gov, … A neutral broadband network is one that is free of restrictions on content, sites, or platforms, on the kinds of equipment that may be attached, and on the modes of communication allowed, as well as one where communication is not unreasonably degraded by other communication streams.[1][2][3] Though the term did not enter popular use until several years later, since the early 2000s advocates of net neutrality and associated rules have raised concerns about the ability of broadband providers to use their last mile infrastructure to block Internet applications and content (e.g. websites, services, protocols); particularly those of competitors. In the US particularly, but elsewhere as well, the possibility of regulations designed to mandate the neutrality of the Internet has been subject to fierce debate. Neutrality proponents claim that telecom companies seek to impose a tiered service model more for the purpose of profiting from their control of the pipeline rather than for any demand for their content or services. Others have stated that they believe net neutrality to be primarily important as a preservation of current freedoms.[4] Vinton Cerf, co-inventor of the Internet Protocol, Tim Berners Lee, father of the web, and many others have spoken out strongly in favour of network neutrality. Opponents of net neutrality include large hardware companies and members of the cable and telecommunications industries. Critics characterised net neutrality regulation as "a solution in search of a problem", arguing that broadband service providers have no plans to block content or degrade network performance.[5] Critics also argue that data discrimination of some kinds, particularly to guarantee quality of service, is not problematic, but highly desirable. Bob Kahn, Internet Protocol's co-inventor, has called "net neutrality" a slogan, and states that he opposes establishing it, warning that "nothing interesting can happen inside the net" if it passes: "If the goal is to encourage people to build new capabilities, then the party that takes the lead in building that new capability, is probably only going to have it on their net to start with and it is probably not going to be on anybody else's net."[6]

4 Administrivia http://students.cec.wustl.edu/~ejm3/ Lab Section C
Help Session Today: 2-4PM in Sever 201 Lab assignment due Wednesday Quiz Monday

5 Lab Questions

6 Methods Black Box – executes a code segment Can take in arguments
Can return a result Plus num1, num2 num Allows us to encapsulate some block of code and give it a name Can then call the block of code over and over and just pass different arguments

7 Method Structure Data Type Name List of Formal Parameters Body
Possibly a return statement <dataType> <name>(<dataType> <name>,…) { //procedure body return <expression>; }

8 Calling a Method How do we call/invoke this method:
double circleArea(double radius) { return radius * radius * ; } circleArea(3.0); double area = circleArea(3.0); How do we invoke this method and set the result to a variable named area of type double?

9 Formal Parameters How are actual parameters bound to formal parameters? double perimeter(int side1, int side2, int side3) { return side1 + side2 + side3; } int length = perimeter(3, 4, 5);

10 Method Example Code

11 Variables Def: A symbol which can hold a value of a particular type
<dataType> <name>; 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 A symbol which can hold a value of a particular type

12 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); AKA attributes

13 Class Layout A Class is a blueprint for an object Class consists of:
It models something Class consists of: Instance/Data Variables Describe Methods Perform Actions 1 class to model a user, many users Usually, a class represents a person, place, or thing - it is an abstraction of a concept within a computer program. Fundamentally, it encapsulates the state and behavior of that which it conceptually represents. It encapsulates state through data placeholders called member variables; it encapsulates behavior through reusable code called methods. Instance variables: noun Methods: verbs Let’s sketch out a car class

14 Instance Example Code

15 Assignment Lab 1 due Wednesday Readings Monday AD Chapter 4: 4.1 - 4.7
KG Notes


Download ppt "Introduction to Computer Programming"

Similar presentations


Ads by Google