1 / 28

CIS 199 Test 02 Review

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.

garth-west
Download Presentation

CIS 199 Test 02 Review

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. CIS 199 Test 02 Review

  2. 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…”

  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 • 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 aRandom Object

  15. Usage & Expected Resultsof 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 • Methods • Break out ‘steps’ • Easier to test • Easier to visualize

  18. Methods &Modularizing Your CodeExample

  19. Arrays

  20. Arrays

  21. Sample Questions fromBlackboard Wiki

  22. 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? • PRECONDITIONS • 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? • VOID 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-Thursday8:00am – 8:00pm • Friday8:00am – 4:00pm • Sunday12:00pm – 2:00pm (CRC Only)

More Related