cis 199 test 02 review

28
CIS 199 Test 02 Review

Upload: garth-west

Post on 31-Dec-2015

30 views

Category:

Documents


0 download

DESCRIPTION

CIS 199 Test 02 Review. Loops. for “For a given value X, while X is true, modify X…” while “While X is true…” do – while “Do these tasks, while X is true…” foreach “For every X in this set of Y do the following…”. for Example. while Example. do while Example. foreach Example. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CIS 199 Test 02 Review

CIS 199 Test 02 Review

Page 2: CIS 199 Test 02 Review

Loops for

“For a given value X, while X is true, modify X…”

while “While X is true…”

do – while “Do these tasks, while X is true…”

foreach “For every X in this set of Y do the following…”

Page 3: CIS 199 Test 02 Review

for Example

Page 4: CIS 199 Test 02 Review

while Example

Page 5: CIS 199 Test 02 Review

do while Example

Page 6: CIS 199 Test 02 Review

foreach Example

Page 7: CIS 199 Test 02 Review

Key Loop Details Loops are NOT guaranteed to execute at least once!

…only exception is ‘do while’

‘for’ loops require a variable, condition, and ‘step’ instruction ‘while’, ‘do while’ loops require a boolean expression ‘foreach’ loops require a collection of items

Arrays Lists Generic Collections

Page 8: CIS 199 Test 02 Review

Files OpenFileDialog

Used to load file from location

SaveFileDialog Used to select file save location

BOTH very User friendly!

Page 9: CIS 199 Test 02 Review

OpenFileDialog

Page 10: CIS 199 Test 02 Review

OpenFileDialog

Page 11: CIS 199 Test 02 Review

SaveFileDialog

Page 12: CIS 199 Test 02 Review

SaveFileDialog

Page 13: CIS 199 Test 02 Review

Random Numbers in C# Provided from: System.Random Is ONLY pseudo-random

Produces a finite set of values with equal probability Not truly random, follows a mathematical algorithm

Created with OR without seed value Common methods used:

Next() Next(int) Next(int, int) NextDouble()

Page 14: CIS 199 Test 02 Review

Creating and using aRandom Object

Page 15: CIS 199 Test 02 Review

Usage & Expected Resultsof Random Methods

Page 16: CIS 199 Test 02 Review

Methods Actions, code to be executed May return a value, may take value (not required) Can be controlled via scope keywords Can be static

Page 17: CIS 199 Test 02 Review

Methods &Modularizing Your Code Methods

Break out ‘steps’ Easier to test Easier to visualize

Page 18: CIS 199 Test 02 Review

Methods &Modularizing Your CodeExample

Page 19: CIS 199 Test 02 Review

Arrays

Page 20: CIS 199 Test 02 Review

Arrays

Page 21: CIS 199 Test 02 Review

Sample Questions fromBlackboard Wiki

Page 22: CIS 199 Test 02 Review

The ‘switch’ statement can replace nested if/else. But under what conditions? When matching on a specific…

Value Type Enumeration …other data

Page 23: CIS 199 Test 02 Review

What does a ‘break’ statement do in a loop? It stops (BREAKS) loop execution Code continues, no further loop iterations

Page 24: CIS 199 Test 02 Review

What does a ‘continue’ statement do in a loop? Goes to the next iteration CONTINUES loop execution, by skipping current iteration

Page 25: CIS 199 Test 02 Review

What are preconditions and postconditions for a method? PRECONDITIONS

Conditions that MUST be TRUE before method execution

POSTCONDITIONS Conditions that WILL be TRUE after method execution

Page 26: CIS 199 Test 02 Review

What is the difference between a void method and a value-returning method? VOID Method

Returns nothing! …a void return.

Value-Returning Returns a value! …that’s not a void return.

Page 27: CIS 199 Test 02 Review

Compare and contrast the use of pass by value against pass by reference, using key word ref versus pass by reference using keyword out. Pass by Value

Passes a copy of the value Not the object itself

Pass by Reference Passes the actual object itself

‘ref’ Causes a pass by reference on a variable

‘out’ Is used to reference a variable that the method will update

Page 28: CIS 199 Test 02 Review

How can REACH further help you today?

Ask Questions Now! Need to see an Example? Need to see a concept again? Need additional help?

Visit us at: iTech Zone CRC (Ekstrom Library)

Monday-Thursday8:00am – 8:00pm

Friday8:00am – 4:00pm

Sunday12:00pm – 2:00pm (CRC Only)