OOP Android Club 2015. DO NOT REMEMBER! TRY TO UNDERSTAND!

Slides:



Advertisements
Similar presentations
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
C++ Classes & Data Abstraction
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look 1 Xiang Lian The University of Texas – Pan American Edinburg,
CS0007: Introduction to Computer Programming Introduction to Classes and Objects.
Chapter 6: A First Look at classes. Object-Oriented Programming  Object-oriented programming is centered on creating objects rather than procedures.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter3: Introduction to Classes and Objects 1.
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
Object-oriented analysis (OOA) techniques are used to (1) study existing objects to see if they can be reused or adapted for new uses, and (2) define new.
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Classes in C++ Bryce Boe 2012/08/15 CS32, Summer 2012 B.
Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.
Arrays and Objects OO basics. Topics Basic array syntax/use OO Vocabulary review Simple OO example Instance and Static methods Static vs. instance vs.
Eclipse – making OOP Easy
Class & Object 蔡柏灃.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA Prof. Dr. Paulo Brasko Ferreira Fall 2014.
Classes and Objects. Topics The Class Definition Declaring Instance Member Variables Writing Instance Member Methods Creating Objects Sending Messages.
Starting Out With Java 5 (Control Structures to Objects) Chapter 6 By Tony Gaddis Copyright © 2005 Pearson Addison-Wesley. All rights reserved.
Starting Out with Java: From Control Structures through Objects.
CS 2430 Day 9. Announcements Quiz on Friday, 9/28 Prog1: see , see me as soon as possible with questions/concerns Prog2: do not add any public methods.
Chapter 8. About the Midterm Exam.. Exam on March 12 Monday (Tentatively) Review on March 7 Wednesday Cover from Chapter 6 Grades will be out before spring.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
CLASSES AND OBJECTS Object-Oriented Basics. Vocabulary Review – C++ Class Object Instance this new Constructor Default constructor Access (private/public/protected)
© 2010 Pearson Addison-Wesley. All rights reserved. 6-1 Chapter Topics Chapter 6 discusses the following main topics: –Classes and Objects –Instance Fields.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
OOP Basics Classes & Methods (c) IDMS/SQL News
Chapter 5 Classes Essential C# Mark Michaelis Ch. 51 Excerpted from Essential C# 4.0 by Mark Michaelis (ISBN: ). Copyright 2010 Pearson Education,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Inheritance & Polymorphism Android Club Agenda Inheritance Polymorphism.
Object means a real word entity such as pen, chair, table etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
INTRODUCTION TO CLASSES & OBJECTS CREATING CLASSES USING C#
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
CE-105 Spring 2007 By: Engr. Faisal ur Rehman
Introduction to Object-oriented Programming
OOP: Encapsulation &Abstraction
Classes and Objects.
COMPUTER 2430 Object Oriented Programming and Data Structures I
A first Look at Classes.
Introduction to Object-oriented Program Design
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Object Based Programming
Classes & Objects: Examples
Object oriented vs procedural programming
CS2011 Introduction to Programming I Objects and Classes
OO Design with Inheritance
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Object Oriented Design & Analysis
ITE “A” GROUP 2 ENCAPSULATION.
CSG2H3 Object Oriented Programming
Presentation transcript:

OOP Android Club 2015

DO NOT REMEMBER! TRY TO UNDERSTAND!

Agenda Class Object Encapsulation Abstraction Inheritance Polymorphism

WHAT is OOP? Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic.objects

Procedural programming

OOP

WHY to use OOP? Easy to design Easy to maintain Reusable code

HOW? Create Class Create Object of class

Class a class is an extensible program-code- template Includes: Variables Methods

Object Instance of class Экземпляр

Class example

Object example

Class iPhone: example public class Iphone { public static int capacity; public static String color; public void turnOn(){ System.out.println("Turning on"); }

Object iphone: example Iphone firstIphone = new Iphone(); firstIphone.capacity = 16; firstIphone.color = "White"; Iphone secondIphone = new Iphone(); firstIphone.capacity = 32; firstIphone.color = "Black";

Object iphone: practice Create new iphone object: thirdIphone Capacity: 128 Color: Gold Turn On

Class example

Object example

Create class: practice Create class: Android Create following Strings name  head  body  rightHand  leftHand  rightLeg  leftLeg

Class methods: practice Create method: jump Access modifier: public Returns: nothing Does: Print “Jumping android”

Class methods: practice 2 Create another method: dance Access modifier: public Returns: nothing Does: Print “Dancing like robot”

Object: practice ANVAR ANDREW ANDRUXA

Encapsulation Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods.

Инкапсуляция Инкапсуляция (по-русски: «сокрытие») — это свойство объектов скрывать некоторые свои данные и способы их обработки (методы) от окружающей его цифровой среды и, в частности, от кривых ручонок малоопытных программистов, оставляя «снаружи» только необходимые и/или требуемые свойства и функциональные возможности.

Do not show process

Encapsulation: Hide process

Encapsulation: example int day; int hour; int minute; int second; public void setDay(int d) { this.day = d; } public int getDay() { return day; }

Encapsulation: practice Create getter&setter for hour Create getter&setter for minute Create getter&setter for second

Encapsulation: create object Clock clock = new Clock(); clock.setDay(17);

Create object: practice Set hour Set minute Set second

Create object: practice2 Create another Clock object: clock2 Set day: 18 Hour: 0 Minute:5 Second: 45

Create object: practice3 Create another Clock object: clock3 Set day: 17 Hour: 15 Minute: 5 Second: 45

Create object: constructor Constructor – method where we initialize our class Clock clock = new Clock();

Empty constructor: example public Clock(){ }

Constructor: example public Clock(){ day = 17; hour = 20; minute = 5; second = 45; }

Constructor: practice Create constructor inside Android class Default values: Head: “white” Body: “white” Right hand: “white” Left hand: “white” Right leg: “white” Left leg: “white”

Constructor: practice2 Create constructor for Iphone class Capacity: 16 Color: “Black”

Setting values with constructor public Clock(int d, int h, int m, int s){ day = d; hour = h; minute = m; second = s; }

Setting values: practice Open class: Iphone Create constructor Using this constructor, create object: Iphone object Pass values Capacity: 16 Color: “White”

Setting values: practice2 Open class: Android Create constructor Using this constructor, create object: andrey Pass values: Name: Andrey Set colors for body parts

SUPER PRACTICE Create Class: Book Variables: title, author, isbn Methods: getters & setters Create constructor Create one Book object, set values using setters Create another Book object, set values using constructor

Project Euler

Questions? Any questions?

Review Lynda.com – Chapter 9. Creating Custom Classes

Homework

Thank you Thank you for your attention!