object oriented programming intro
TRANSCRIPT
Object Oriented Programming
Using Java
Programming so far…Procedural
– Basic (quitebasic.com)
– Console in VB.net
Event Driven- Forms in VB.net
Object Orientated
‘hidden’ in VB.net… code for components of event driven!
Key Terminology
• Parameters
• Data Types
• State
• Source code
• Class
• Object
• Inheritance
• Method
Objects and Classes
Class
• “Objects of a particular kind” (Barnes and Kolling 2012)
• Hold the similar properties but with different values
• ‘Real’ objects or data
– (tangible or intangible/virtual)
‘Real’ Objects (Chapter 1 Figures)
Triangle: object properties
• 3 sides!
• Blue
• Equilateral
• Position: Bottom-left
New Triangle
• Still 3 sides!
• Green
• Isosceles
• Position: Centred
Methods
An instruction to do something to a specific object (using set parameters) e.g.
• Void changeColor(String newColor)
• Void makeVisible()
• Void moveLeft()
• Void slowMoveHorizontal(int distance)
BlueJ example (Chapter 1 House)
• Double-click a class or right click and Open Source Code
– Familiar in any ways?
• Create new objects and apply methods to arrange a pattern
• Inspect and compare the objects’ states
BlueJ example (Chapter 1 lab-classes)
• Parameters
• Data types
DataCraig’s example: (next week!)
Classes/objects:• Trains
– Train1– Train2– …
• Passengers– Craig– Jenny– …
• Stations– Worthing– Goring– Angmering– …
Data• Train1 stops at Worthing at 1pm.
Craig gets on:• Train1 stops at Goring at 1:10pm.
Jenny gets on, Craig gets off:• Train1 stops at Angmering at
1:18pm. Jenny gets off:
Discuss and create diagrams of the classes and data flow of the situation