LaTeX Notes - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

LaTeX Notes

Description:

... of a parent' class by inheriting core functionality into a child' class. ... and store in it different kinds of shapes (provided they inherit from TShape) ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 18
Provided by: hsa8
Category:

less

Transcript and Presenter's Notes

Title: LaTeX Notes


1
LaTeX Notes
All Latex files must have the extension
.tex Create LaTeX files using an ordinary text
editor. Skeleton LaTeX file \documentclassarti
cle \begindocument text goes
here \enddocument
2
LaTeX Notes
Use latex myfile to compile a latex file Use
xdvi myfile to view a compiled latex file Use
dvipdf myfile to generate a pdf file of your
compiled latex file.
3
LaTeX Notes
Generating math equations Equations are
indicated by eg x2 To write a
math fraction, use \fracdxdy To write large
brackets, use \left( and \right)
4
LaTeX Notes
To do a section heading use \sectionAssignment
3 Example math equation \fracddx x2
2 x
5
Object Orientated Programming
The fundamental unit of OOP is the
object. Objects are simply an encapsulation of
data and functions that act on data. TCircle
class double x, y, radius double
area() return 23.1415radius

6
Object Orientated Programming
TCircle circle circle.radius 12.3 print
circle.area() The reason for this
representation is that real-world entities have
an analogous grouping, so OOP tries to enable a
programmer to describe a problem in a more
natural way. Thus a real-world circle has
dimensional properties but it also has a set of
operations that can be applied to it.
7
Object Orientated Programming
CLASS A class is a blue-print for an
object. OBJECT An object is an actual instance
of a class
8
Object Orientated Programming
  • Three three main concepts in OOP are
  • Encapsulation
  • Inheritance
  • Polymorphism

9
Object Orientated Programming
  • Three three main concepts in OOP are
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Encapsulation allows a programmer to hide
    unnecessary details from another programmer.
  • It also allows a programmer to protect code from
    accidental corruption. The end result is more
    robust program development.

10
Object Orientated Programming
Inheritance Inheritance is the ability to build
new classes based on existing classes. In other
words it allows one to extend the behaviour of a
parent class by inheriting core functionality
into a child class.
11
Object Orientated Programming
TCircle class double x, y, radius
TColor fillColor, penColor double area()
void draw() . TSquare class
double x, y, w, h TColor fillColor,
penColor double area() void
draw() .
12
Object Orientated Programming
TShape class double x, y TColor
fillColor, penColor TSquare class inherit
from TShape double w, h double area()
void draw() . TCircle class
inherit from TShape double radius
double area() void draw() .
13
Object Orientated Programming
Inheritance introduces the idea of specialization
and generalization. Inheritance also encourages
code reuse. Taxonomy is the classic
inheritance problem.
14
Object Orientated Programming
Polymorphism This feature allows a programmer to
treat related objects in the same way. Each of
our shapes has a draw function. This is used to
draw the object on the screen. To create a
polymorphic draw function we need to declare an
empty draw function in the parent class called a
virtual function. A virtual function doesnt
actually have any code, its just a declaration
of intent.
15
Object Orientated Programming
Polymorphism In child classes, we now declare
all our draw() functions as overriding the
parent draw() function. TShape class void
draw() virtual TCircle class inherits from
TShape override void draw() ..

16
Object Orientated Programming
Polymorphism We can create an entire family of
shapes where each shape overrides the draw()
function. But why bother? It means that if I
receive a shape variable and I want to draw it, I
no longer have to worry about what shape it
actual is. For example I can now create an array
of TShapes and store in it different kinds of
shapes (provided they inherit from TShape). If I
want to draw each shape all I do is for (i 0
IltnShapes I) shapesi.draw()
17
Object Orientated Programming
Application
Write a Comment
User Comments (0)
About PowerShow.com