Presentation is loading. Please wait.

Presentation is loading. Please wait.

CIS 199 Test 02 Review.

Similar presentations


Presentation on theme: "CIS 199 Test 02 Review."— Presentation transcript:

1 CIS 199 Test 02 Review

2 Loops for while do – while foreach
“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…”

3 for Example

4 while Example

5 do while Example

6 foreach Example

7 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

8 Files OpenFileDialog SaveFileDialog BOTH very User friendly!
Used to load file from location SaveFileDialog Used to select file save location BOTH very User friendly!

9 OpenFileDialog

10 OpenFileDialog

11 SaveFileDialog

12 SaveFileDialog

13 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()

14 Creating and using a Random Object

15 Usage & Expected Results of Random Methods

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

17 Methods & Modularizing Your Code
Break out ‘steps’ Easier to test Easier to visualize

18 Methods & Modularizing Your Code Example

19 Arrays

20 Arrays

21 Sample Questions from Blackboard Wiki

22 The ‘switch’ statement can replace nested if/else
The ‘switch’ statement can replace nested if/else. But under what conditions? When matching on a specific… Value Type Enumeration …other data

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

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

25 What are preconditions and postconditions for a method?
Conditions that MUST be TRUE before method execution POSTCONDITIONS Conditions that WILL be TRUE after method execution

26 What is the difference between a void method and a value-returning method?
Returns nothing! …a void return. Value-Returning Returns a value! …that’s not a void return.

27 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

28 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-Thursday 8:00am – 8:00pm Friday 8:00am – 4:00pm Sunday 12:00pm – 2:00pm (CRC Only)


Download ppt "CIS 199 Test 02 Review."

Similar presentations


Ads by Google