Lecture 4 - GUI Programming II

Lecture 4 - GUI Programming II - EEE13 Lecture 2 Review

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EEE13 Lecture 2 Review MVC, OOP, GUI Programming Lecture 2 Agenda • Model-View-Controller  (MVC) model • Object Oriented Programming (OOP) • GUI Programming MVC Illustration http://book.cakephp.org/view/10/Understanding-Model-View-Controller MVC Example • View  • Web Page • Controller • Scripts that generate HTML page • Sends data to Server • Model  • Database system Object Oriented Programming • Class • Describes common characteristics of objects in  terms of  • variables (properties/attributes)  • functions (methods) • Object • Variables declared of a particular class. • Actual instance of a class • Inheritance • Polymorphism Inheritance • Special relationship between classes • A more specific class obtains the characteristics of  a more general class (base class) • Methods of the more general class are still  available in the derived class • Methods are usually customized (overridden) • Inheritance can be treated as an “is an”  relationship. Polymorphism  Polymorphism is in short the ability to call  different functions by just using one type of  function call.  It is useful since it can group classes and their  functions together.  Polymorphism Example Example: We want to draw a picture consisting of circles, squares, lines and triangles. So we  can make a class Shape and create an instance of it like this:       Shape *s[100]; Now all the addresses of the objects of the other classes (line, circle, etc.) are stored  in the Shape Array. And then to draw the Picture all we have to do is this:    for(int i=0;i<=100;i++)        s[i]->draw(); Now as the loop runs different draw functions of each class is called. This is great  because: • Functions from different classes are executed through the same function call. • The Array s[] has been defined to contain shape pointers and not square or triangle pointers.  http://74.125.95.132/search?q=cache:lK4s2MEteEIJ:www.programmers-corner.com/tutorial/36+push+and+pop+polymorphism&cd=4&hl=en&ct=clnk&gl=ph Polymorphism Example (cont.) Now how do we know which version of draw() would be called  during execution? Which draw() function would get used  depends on the contents of s[i].But for this polymorphic  approach to work we must satisfy the following conditions:   • The Base class must contain a draw() function which is declared  virtual. • All other classes (line, circle, etc.) should be derived from the base  class....
View Full Document

This note was uploaded on 01/13/2011 for the course EEEI 13 taught by Professor Ramos during the Winter '10 term at University of the Philippines Diliman.

Page1 / 46

Lecture 4 - GUI Programming II - EEE13 Lecture 2 Review

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online