Cis166 final review

415 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
415
On SlideShare
0
From Embeds
0
Number of Embeds
86
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cis166 final review

  1. 1. CIS-166 Final <ul><li>Open book, open notes, open computer </li></ul><ul><li>100 points </li></ul><ul><li>True/false, multiple choice, fill-in, short answer </li></ul><ul><li>Emphasis on material since midterm </li></ul>
  2. 2. Object Terminology Review <ul><li>Object - like a noun, a thing </li></ul><ul><ul><li>An object is based on a class </li></ul></ul><ul><li>Properties - like an adjective, characteristics of object </li></ul><ul><li>Methods - like a verb, an action or behavior, something the object can do </li></ul><ul><li>Events - object response to user action or other events </li></ul>
  3. 3. Polymorphism <ul><li>Overloading: Argument type determines which version of a method is used </li></ul><ul><ul><li>Example: MessageBox.Show method </li></ul></ul><ul><li>Overriding: Refers to a class that has the same method name as its base class </li></ul><ul><ul><li>Method in subclass takes precedence </li></ul></ul>
  4. 4. Specifying a Namespace <ul><li>Namespaces are used in .Net to organize classes and source files </li></ul><ul><li>When referring to classes in a different namespace </li></ul><ul><ul><li>Write out the entire namespace </li></ul></ul><ul><ul><li>Add an Imports Statement to include the namespace </li></ul></ul>Public Class Form1 Inherits System.Windows.Forms.Form Name of the Class Namespace
  5. 5. Instance versus Shared Variables <ul><li>Instance variables or properties use a separate memory location for each instance of the object </li></ul><ul><li>Shared variables or properties use a single memory location that is available for ALL objects of a class </li></ul><ul><ul><li>Can be accessed without instantiating an object of the class </li></ul></ul><ul><ul><li>Use the Shared keyword to create </li></ul></ul>Shared Methods can also be created
  6. 6. Constructors and Destructors <ul><li>Constructor: Method that automatically executes when an object is instantiated </li></ul><ul><ul><li>Create by writing a Public Sub New procedure </li></ul></ul><ul><li>Destructor: Method that automatically executes when an object is destroyed </li></ul><ul><ul><li>Create by writing a Finalize procedure </li></ul></ul>
  7. 7. Collections <ul><li>Group of objects </li></ul><ul><ul><li>Can be strongly typed: all objects based on the same class </li></ul></ul><ul><li>Similar to an array </li></ul><ul><ul><li>Collection expands and contracts automatically </li></ul></ul><ul><li>Have common properties and methods </li></ul><ul><ul><li>Add, Remove, Count, Item </li></ul></ul>
  8. 8. Item Property <ul><li>Typically set as default property for a collection </li></ul><ul><li>Returns a member of the group </li></ul><ul><ul><li>Typically based on an Index </li></ul></ul><ul><ul><li>Data type depends on the type of objects the collection manages </li></ul></ul>
  9. 9. Text Data Files <ul><li>Actual data stored in files on disk device </li></ul><ul><li>File ==> Entire collection of data of data </li></ul><ul><li>Records ==> Rows or lines, one per entity </li></ul><ul><li>Fields ==> Data elements within row </li></ul>
  10. 10. Text File Handling <ul><li>A Stream is designed to transfer a series of bytes from one location to another </li></ul><ul><li>Streams are objects that have properties and methods </li></ul><ul><li>Found in the System.IO namespace </li></ul><ul><li>File handling projects usually contain an Imports statement before the statement declaring the form's class </li></ul>
  11. 11. Writing Data Files <ul><li>Declare a new StreamWriter object </li></ul><ul><li>Use StreamWriter's WriteLine method </li></ul><ul><li>Call StreamWriter's Close method </li></ul>
  12. 12. Write and WriteLine Methods <ul><li>Write Method: Places items consecutively in the file with no separator </li></ul><ul><li>WriteLine Method: Places an Enter (carriage return) between records </li></ul>
  13. 13. Reading Files <ul><li>Declare a new StreamReader object </li></ul><ul><ul><li>File must exist! </li></ul></ul><ul><li>Use StreamReader's ReadLine method </li></ul><ul><ul><li>Loop to retrieve multiple records </li></ul></ul><ul><li>Call StreamReader's Close method </li></ul>
  14. 14. ReadLine Method <ul><li>Use to read previously saved data </li></ul><ul><li>Each time it executes, it reads the next line of data </li></ul><ul><li>Always assign the value from the read to a location, such as a label, text box, or string variable </li></ul>
  15. 15. Checking for End of File <ul><li>Use StreamReader's Peek Method </li></ul><ul><li>Peek looks at the next element without actually reading it </li></ul><ul><li>If you Peek beyond the last element the value returned is -1 </li></ul>

×