CS 112 Introduction to Programming - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

CS 112 Introduction to Programming

Description:

CS 112 Introduction to Programming. Lecture #37: Review ... jagged arrays. arrays of arrays. arrays that compose jagged arrays can be of different lengths, e.g. ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 13
Provided by: Richar9
Category:

less

Transcript and Presenter's Notes

Title: CS 112 Introduction to Programming


1
CS 112 Introduction to Programming
  • Lecture 37
  • Review
  • Http//zoo.cs.yale.edu/classes/cs112/

2
Admin.
  • Exam 2 Thursday (tomorrow) evening
  • location DL 220
  • time 7-9 PM
  • office hours
  • Wednesday (today)
  • 2-3 PM (AKW 202)
  • 8-1030 PM (DL 120)
  • Thursday
  • 3-430 PM (DL 120)

3
Basic Topics Covered
  • Arrays (4)
  • strings
  • Object-oriented programming (4)
  • GUI/event driven programming/graphics (4)
  • Recursion
  • recursive methods (4)
  • recursive data structures (1)
  • Exception handling (1)

4
Arrays Declaration, Initialization, and Access
  • 1D array
  • int array1 new int 1, 2, 3
  • int array2 new int3
  • array12 10
  • Multi-dimensional array
  • rectangular arrays
  • int, array3 new int, 1, 2, 3 , 4, 5,
    6
  • int, array4 new int3,4
  • jagged arrays
  • arrays of arrays
  • arrays that compose jagged arrays can be of
    different lengths, e.g.,
  • int array5 new int 3 array5 0
    new int 1, 2 array5 1 new int 3
    array5 2 new int 4, 5, 6
    array521 3

5
Array A String As Character Array
  • A string is essentially an encapsulation of an
    array of characters
  • string str abc
  • Console.WriteLine( str0 )
  • static void Main( string args )
  • Console.WriteLine( args01 )
  • Some commonly used functions of the String class
  • method ToUpper
  • method ToLower
  • method Format

6
Array Some Usage
  • Store multiple data items
  • Same type
  • Related with polymorphism
  • Array elements as counters

7
Object-Oriented Design Inheritance
  • Why inheritance
  • code reuse
  • polymorphism (extensible and elegant design)
  • Controlling inheritance
  • private, protected, public
  • override, virtual
  • Class hierarchy the object class ToString()
  • Extending the basic idea of inheritance
  • Abstract class
  • Interface

8
GUI
  • Example components/controls
  • Label
  • TextBox
  • Button
  • PictureBox
  • Timer
  • Media Player MS Agent
  • Controlling layout of a Windows application
  • GroupBox and Panel
  • Anchor and Dock
  • Events and event handler
  • Buttons, e.g., Click event
  • Mouse, e.g., MouseDown, MouseUp, MouseMove
  • Keyboard, e.g., KeyPress
  • Timer

9
Graphics
  • Graphics
  • Graphics context coordinate system some
    graphics methods, e.g., DrawLine Pen
  • When to draw OnPaint, Paint event handler, and
    Invalidate method call extract graphics context
    from argument, i.e., e.Graphics

10
Recursion
  • Recursive methods
  • define method structure
  • define recursive case
  • define base case
  • recursive search
  • keep state, e.g., Maze
  • backtrack, e.g., Knights tour
  • Recursive data structures
  • linked list
  • definition
  • implementation of enumeration, insertions and
    deletions for linked lists
  • other potential recursive data structures
  • choose the right data structure array or linked
    list

11
Exceptions
  • Why exception?
  • Some common exceptions
  • System.Exception
  • System.SystemException
  • System.FormatException
    System.ArithmeticException
  • System.DivideByZeroException
  • System.OverflowException
    System.IndexOutOfRangeException
  • Properties Message, StatckTrace
  • How to handle exceptions catch, try, and finally

12
Summary
  • storing data
  • primitive data types
  • classes (inheritance access control)
  • arrays
  • recursive data structure
  • processing data
  • expressions
  • flow of control (e.g., while, for, do/while)
  • methods (overload virtual/override
    decomposition)
  • recursive methods
  • exceptions
  • links between storage and processing
  • classes (encapsulation)
  • data structures (pick efficient storage for
    required processing)
Write a Comment
User Comments (0)
About PowerShow.com