Basic.  Defining functions  Internals and parameters  Returning values  Scoping values  Using functions as filters.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

For(int i = 1; i
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Programming Methodology (1). Implementing Methods main.
Functions Prototypes, parameter passing, return values, activation frams.
Objects contains data and methods Class – type of object Create class first Then object or instance String – defined class String s; // creates instance.
Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
Chapter 8 Scope, Lifetime and More on Functions. Definitions Scope –The region of program code where it is legal to reference (use) an identifier Three.
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Introduction to Computers and Programming Introduction to Methods in Java.
Overloading methods review When is the return statement required? What do the following method headers tell us? public static int max (int a, int b)
Basic.  Powershell scripts are flat text files that end with “.ps1” (e.g. myscript.ps1)  Similar to other scripting languages, whatever you can do on.
1 What’s a class People are confused with nested classes and anonymous classes. Experiments in a recitation last week revealed that the problems were probably.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Unit 2: Java Introduction to Programming 2.1 Initial Example.
COMP More About Classes Yi Hong May 22, 2015.
SE-1010 Dr. Mark L. Hornick 1 Defining Your Own Classes Part 3.
ITP © Ron Poet Lecture 13 1 Helper Objects. ITP © Ron Poet Lecture 13 2 Console Helper Object  We have used Console objects for a while, let’s see what.
 $10.65 x 40 = $  $ x 50 = $21,
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Chapter 3.6 Variation. Direct Variation When one quantity is a constant multiple of another quantity, the two quantities are said to vary directly. For.
To access our web services, go to……. Click on Customer Login.
Agenda Object Oriented Programming Reading: Chapter 14.
Audacity AP Spanish. Installing Audacity
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
PART 1 Part 1: The Material. Whether you knew it or not, all the programming that you have performed until now was in the boundaries of procedural programming.
Coinage Analysis Once you have exported the “ABA” or bank file from your payroll program, open the Coinage Analysis. Click to locate file.
How to design and code functions Chapter 4 (ctd).
The Math class Java provides certain math functions for us. The Math class contains methods and constants that can be very useful. The Math class is like.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
AP Computer Science A – Healdsburg High School 1 Unit 9 - Parameter Passing in Java.
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
Methods. Creating your own methods Java allows you to create custom methods inside its main body. public class Test { // insert your own methods right.
Staples are our staple Building upon our solution.
1 Advanced Programming Examples. using System; class Test { static void Main( string[] args ) { int a = 7; int b = 3; int c = 5; int d = 9; Console.WriteLine(!(d.
Computer Programming Your First Java Program: HelloWorld.java.
Examples of Classes & Objects
AKA the birth, life, and death of variables.
using System; namespace Demo01 { class Program
Lecture 7: Android Services
function definition How to build a color house with number bedrooms.
Sum of natural numbers class SumOfNaturalNumbers {
Java Course Review.
Building Java Programs

CHAPTER 8 (skip , ) CHAPTER 10
Functions Used to write code only once Can use parameters.
Lecture 11 C Parameters Richard Gesick.
Structures putting data together.
Classes & Objects: Examples
AP BIOLOGY AUGUST 2013 OPENING ASSIGNMENTS.
Structures putting data together.
Java Lesson 36 Mr. Kalmes.
Command Line Parameters
CS2011 Introduction to Programming I Methods (II)
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
AKA the birth, life, and death of variables.
Take out a piece of paper and PEN.
class PrintOnetoTen { public static void main(String args[]) {
Tonga Institute of Higher Education
Scope of variables class scopeofvars {
Scope scope: The part of a program where a variable exists. From its declaration to the end of the { } braces A variable declared in a for loop exists.
Category Category Category Category Category.
2 Hours Minutes Seconds Insert Text Here.
Category Category Category Category Category.
Object Oriented Programming
Scope Rules.
Presentation transcript:

Basic

 Defining functions  Internals and parameters  Returning values  Scoping values  Using functions as filters

 Function Function ( ) { }

function Write-PayCheck1 ($hours, $wage, $name) { $pay = $hours * $wage write-host "Pay to the order of " $name “: “ $pay } function Write-PayCheck2 ([int] $hours, [int] $wage, [string] $name) { $pay = $hours * $wage $wline = ("Pay to the order of {0}...{1:c2}" -f $name, $pay) write-host $wline -f Red } function Write-PayCheck3() {param($hours = 40, $wage, $name) $pay = $hours * $wage write-host "Pay to the order of " $name “: “ $pay }

function Write-PayCheck4() { $hours = $args[0] $wage = $args[1] $name = $args[2] $pay = $hours * $wage write-host "Pay to the order of " $name “: “ $pay }

function Count-Objects { begin { $lineCount = 0 } process { $lineCount++ } end { Write-Host "There are " $lineCount " lines." } Get-EventLog -List | Count-Objects

 $profile provides the location of Microsoft.PowerShell_profile.ps1  You can place your customized functions here  OR you can keep them in a.ps1 file for later use and “source” the file. Example:..\myFunctions.ps1 Dot SpaceYour File