Introduction To Object-Oriented Programming
Introduction To Object-Oriented Programming
Introduction To Object-Oriented Programming
Introduction to Object-Oriented
Programming
Chapter 1 Topics
Problem-Solving
Implementation
Maintenance
Problem-Solving Phase
Sample Problem
40 x $ 24.75
= $
12 x 1.5 x $ 24.75 = ___________
$ 445.50
$ 1435.50
990.00
RECALL EXAMPLE
( 40 x $ 24.75 ) + ( 12 x 1.5 x $ 24.75 ) = $1435.50
otherwise,
wages = hours * payRate
A class is . . .
a
An Object is . . .
an
instance of a class
a Date object
June
23
2004
10
An Algorithm is . . .
instructions
for solving a
problem in a finite amount of
time using a finite amount of
data
11
A Program is . . .
an
13
A Programming Language is . . .
14
Code is . . .
15
Maintenance Phase
17
18
Programming Shortcut?
PROBLEM-SOLVING PHASE
Problem
Algorithm
Shortcut?
Code
TEST
THINKING
IMPLEMENTATION
PHASE
CODE
19
1 byte = 8 bits
1 KB
= 1024 bytes
1 MB
20
21
Machine Language
Is not portable
Assembly Languages
23
Are portable
Are translated into machine code by
compilers
Instructions are written in language similar
to natural language
Examples -- FORTRAN, COBOL, Pascal,
C, C++
Many are standardized by ISO/ANSI to
provide an official description of the
language
24
via compiler
myprog.obj
OBJECT
myprog.exe
EXECUTABLE
written
writtenin
in
machine
machine
language
language
written
writtenin
in
machine
machine
language
language
via linker
other
othercode
code
from
fromlibraries,
libraries,
etc.
etc.
25
Java Portability
EXECUTABLES
Payroll.java
Payroll.class
SOURCE
BYTECODE
Windows
WindowsPC
PC
running
runningJVM
JVM
Java
Java
Program
Program
Java
Java
Bytecode
Bytecode
Unix
Unixbox
box
running
runningJVM
JVM
via compiler
via interpreter
JVM
Macintosh
Macintosh
running
runningJVM
JVM
26
28
SEQUENCE
Statement
Statement
...
Statement
29
SELECTION (branch)
IF Condition THEN Statement1 ELSE Statement2
True
Statement1
Statement
Condition
...
False Statement2
30
LOOP (repetition)
WHILE Condition DO Statement1
False
Condition
...
Tru
e
Statement
31
SUBPROGRAM (function)
SUBPROGRAM1
...
SUBPROGRAM1
a meaningful collection
of SEQUENCE,
SELECTION, LOOP,
SUBPROGRAM
32
ASYNCHRONOUS CONTROL
EVENTHANDLER
EVENT
a subprogram executed
when an event occurs
33
Object-Oriented Programming
A data type is the specification in a
programming language of how
information is represented as data and the
operations that can be preformed on the
data
An object is a collection of data values
and associated operations
A class is a description of one or more
like objects
34
35
An Object of class
OPERATIONS
Time
DATA
Set
Increment
Write
.
.
.
Private data:
hrs
mins
25
secs
42
Time
36
Control Unit
Arithmetic Logic Unit
Output Device
Auxiliary
Storage
Device
37
Memory Unit
Unit performs
arithmetic and logical operations
Control Unit controls the order in which
instructions in the program are
executed
39
Peripheral Devices