130 likes | 442 Views
Introduction to Object-Oriented Programming with Java. Lecture 21: Supporting Material Dr Kathryn Merrick Thursday May 28 th , 2009. Overview. Object-oriented design Object-oriented programming Introduction to Java. Activity 1: O-O Design. Object-Oriented Languages.
E N D
Introduction to Object-Oriented Programming with Java Lecture 21: Supporting Material Dr Kathryn Merrick Thursday May 28th, 2009
Overview • Object-oriented design • Object-oriented programming • Introduction to Java
Object-Oriented Languages • Two main levels of encapsulation: • Functions/Methods • Classes/Objects • Classes permit related methods to be: • Grouped together in a logical way • Accessed in a uniform way • Classes can themselves be organised in a hierarchy
First Java Programs – Lego Insects Snail Ant Bee Cricket
The Insect Abstract Class Class comment Class header Properties to be inherited by all child classes Methods to be defined by all child classes
The Snail Class Start point for program Constructor
The Cricket run() method Method comment Method header Constant For loop If selection Method call to method in another class
The Ant: Using Helper Methods Calls to helper methods (in same class) Helper methods
Summary • After this lecture you should be able to define: • Classes/objects • Inheritance • Constructors • Dot operator for method calls • Modifiers • And have an awareness of the differences between Java and Matlab