object oriented programming intro

11
Object Oriented Programming Using Java

Upload: helen-ward

Post on 22-Jan-2018

175 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Object Oriented Programming Intro

Object Oriented Programming

Using Java

Page 2: Object Oriented Programming Intro

Programming so far…Procedural

– Basic (quitebasic.com)

– Console in VB.net

Page 3: Object Oriented Programming Intro

Event Driven- Forms in VB.net

Page 4: Object Oriented Programming Intro

Object Orientated

‘hidden’ in VB.net… code for components of event driven!

Page 5: Object Oriented Programming Intro

Key Terminology

• Parameters

• Data Types

• State

• Source code

• Class

• Object

• Inheritance

• Method

Page 6: Object Oriented Programming Intro

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)

Page 7: Object Oriented Programming Intro

‘Real’ Objects (Chapter 1 Figures)

Triangle: object properties

• 3 sides!

• Blue

• Equilateral

• Position: Bottom-left

New Triangle

• Still 3 sides!

• Green

• Isosceles

• Position: Centred

Page 8: Object Oriented Programming Intro

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)

Page 9: Object Oriented Programming Intro

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

Page 10: Object Oriented Programming Intro

BlueJ example (Chapter 1 lab-classes)

• Parameters

• Data types

Page 11: Object Oriented Programming Intro

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