CIS-166 Final CIS-166 Final Open book, open notes, open computer Open book, open notes, open computer 100 points 100 points True/false, multiple choice, fill- True/false, multiple choice, fill- in, short answer in, short answer Emphasis on material since midterm Emphasis on material since midterm
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CIS-166 FinalCIS-166 Final
Open book, open notes, open computerOpen book, open notes, open computer 100 points100 points True/false, multiple choice, fill-in, short answerTrue/false, multiple choice, fill-in, short answer Emphasis on material since midtermEmphasis on material since midterm
ArraysArrays
List or series of values all referenced by the List or series of values all referenced by the same namesame name
Use an array to keep a series of variables for Use an array to keep a series of variables for later processing such as later processing such as – ReorderingReordering– CalculatingCalculating– PrintingPrinting
Array TermsArray Terms
ElementElement– Individual item in the arrayIndividual item in the array
Index (or subscript)Index (or subscript)– Zero based Zero based number used to reference the number used to reference the
specific elements in the arrayspecific elements in the array– Must be an integerMust be an integer
BoundariesBoundaries– Lower Subscript, 0 by defaultLower Subscript, 0 by default– Upper SubscriptUpper Subscript
Results in an array with 3 elements, each with a value, Results in an array with 3 elements, each with a value, departments[0] is “ACT”departments[0] is “ACT”
Use Loops to reference each element in the Use Loops to reference each element in the arrayarray– For / Next For / Next – For Each / NextFor Each / Next
Object - like a noun, a thingObject - like a noun, a thing– An object is based on a An object is based on a classclass
Properties - like an adjective, characteristics Properties - like an adjective, characteristics of objectof object
Methods - like a verb, an action or behavior, Methods - like a verb, an action or behavior, something the object can dosomething the object can do
Events - object response to user action or Events - object response to user action or other eventsother events
PolymorphismPolymorphism
Overloading: Argument type determines which Overloading: Argument type determines which version of a method is usedversion of a method is used– Example: MessageBox.Show methodExample: MessageBox.Show method
Overriding: Refers to a class that has the same Overriding: Refers to a class that has the same method name as its base classmethod name as its base class– Method in subclass takes precedenceMethod in subclass takes precedence
Specifying a NamespaceSpecifying a Namespace
Namespaces are used in .Net to organize Namespaces are used in .Net to organize classes and source filesclasses and source files
When referring to classes in a different When referring to classes in a different namespacenamespace– Write out the entire namespaceWrite out the entire namespace– Add an Imports Statement to include the namespaceAdd an Imports Statement to include the namespace
Using System.Windows.Forms.Form
Name of the ClassNamespace
Instance versus Static Instance versus Static VariablesVariables
Instance variables or properties use a Instance variables or properties use a separate memory location for each instance separate memory location for each instance of the objectof the object
Static variables or properties use a single Static variables or properties use a single memory location that is available for ALL memory location that is available for ALL objects of a classobjects of a class– Can be accessed without instantiating an Can be accessed without instantiating an
object of the classobject of the class– Use the Use the StaticStatic keyword to create keyword to create
Static Methods can also be created
Constructors and DestructorsConstructors and Destructors
Constructor: Method that automatically Constructor: Method that automatically executes when an object is instantiatedexecutes when an object is instantiated– Create by writing a procedure using the Create by writing a procedure using the
Class Name, followed by any argumentsClass Name, followed by any arguments Destructor: Method that automatically Destructor: Method that automatically
executes when an object is destroyedexecutes when an object is destroyed– Microsoft discourages use of in .NetMicrosoft discourages use of in .Net
CollectionsCollections
Group of objectsGroup of objects– Can be strongly typed: all objects based on Can be strongly typed: all objects based on
the same classthe same class Similar to an arraySimilar to an array
– Collection expands and contracts Collection expands and contracts automaticallyautomatically
Have common properties and methodsHave common properties and methods– Add, Remove, Count, Item (Indexer)Add, Remove, Count, Item (Indexer)
Item PropertyItem Property
Typically default property for a collectionTypically default property for a collection– Refer to collection object, followed by location Refer to collection object, followed by location
(in [])(in []) Returns a member of the groupReturns a member of the group
– Typically based on location, but can use other Typically based on location, but can use other valuesvalues
– Data type depends on the type of objects the Data type depends on the type of objects the collection managescollection manages
Text Data FilesText Data Files
Actual data stored in files on disk deviceActual data stored in files on disk device FileFile ==>==> Entire collection of data ofEntire collection of data of
datadata RecordsRecords ==>==> Rows or lines, one per Rows or lines, one per
entityentity FieldsFields ==>==> Data elements within rowData elements within row
Text File HandlingText File Handling
A A StreamStream is designed to transfer a series is designed to transfer a seriesof bytes from one location to anotherof bytes from one location to another
Streams are objects that have properties Streams are objects that have properties and methodsand methods
Found in the System.IO namespaceFound in the System.IO namespace File handling projects usually contain an File handling projects usually contain an
Imports statement before the statement Imports statement before the statement declaring the form's classdeclaring the form's class
Writing Data FilesWriting Data Files
Declare a new Declare a new StreamWriterStreamWriter object object Use StreamWriter's Use StreamWriter's WriteLineWriteLine methodmethod Call StreamWriter's Call StreamWriter's Close methodClose method
Write and WriteLine MethodsWrite and WriteLine Methods
Write Method: Places items consecutively in the Write Method: Places items consecutively in the file with no separatorfile with no separator
WriteLine Method: Places an Enter (carriage WriteLine Method: Places an Enter (carriage return) between recordsreturn) between records
Reading FilesReading Files
Declare a new Declare a new StreamReaderStreamReader object object– File must exist!File must exist!
Use StreamReader's Use StreamReader's ReadLineReadLine methodmethod– Loop to retrieve multiple recordsLoop to retrieve multiple records
Call StreamReader's Call StreamReader's Close methodClose method
ReadLine MethodReadLine Method
Use to read previously saved dataUse to read previously saved data Each time it executes, it reads the Each time it executes, it reads the nextnext line of data line of data Always assign the value from the read to a location, Always assign the value from the read to a location,
such as a label, text box, or string variablesuch as a label, text box, or string variable
Checking for End of FileChecking for End of File
Use Use StreamReader's Peek MethodStreamReader's Peek Method Peek looks at the next element Peek looks at the next element withoutwithout actually actually
reading itreading it If you Peek beyond the last element the value If you Peek beyond the last element the value