AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example.

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

AP Computer Science A – Healdsburg High School 1 Unit 3 - Classes and Objects - Example.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Department of computer science N. Harika. Inheritance Inheritance is a fundamental Object Oriented concept A class can be defined as a "subclass" of another.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 CS1001 Lecture Overview Homework 3 Homework 3 Project/Paper Project/Paper Object Oriented Design Object Oriented Design.
Starting Classes and Methods. Objects have behaviors In old style programming, you had: –data, which was completely passive –functions, which could manipulate.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
25-Jun-15 Starting Classes and Methods. Objects have behaviors In old style programming, you had: data, which was completely passive functions, which.
Object-oriented Programming Concepts
Chapter 10 Classes Continued
Polymorphism. Lecture Objectives To understand the concept of polymorphism To understand the concept of static or early binding To understand the concept.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object Oriented Programming The object concept. Alan Kay—Smalltalk—5 basic characteristics of OOP 1.Everything is an object. An object is a fancy variable-it.
Turtle Graphics  Turtle graphics provide a simple way to draw pictures in a window.  The name suggests the way in which we can think about the drawing.
BACS 287 Basics of Object-Oriented Programming 1.
Inheritance Inheritance is the process of using features (both attributes and methods) from an existing class. The existing class is called the superclass.
Abstraction, Inheritance, and Polymorphism in Java.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
A class in Java is a software construct that includes fields (also called data fields or class scope variables) to provide data specification, and methods.
Lesson 2: First Java Programs. Objectives: –Discuss why Java is an important programming language. –Explain the Java virtual machine and byte code. –Choose.
Objects and Classes Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary.
An Introduction to Software Development Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006.
CSC 142 Computer Science II Zhen Jiang West Chester University
Turtle Graphics  Turtle graphics provide a simple way to draw pictures in a window.  The name suggests the way in which we can think about the drawing.
Inheritance Inheritance is the process of using features (both attributes and methods) from an existing class. The existing class is called the superclass.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
AP Computer Science A – Healdsburg High School 1 Interfaces, Abstract Classes and the DanceStudio - Similarities and Differences between Abstact Classes.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
© 2000 McGraw-Hill Modified by C.W.Pang with author's permission Intro to OOP with Java--Wu Chapter Chapter 1 Introduction to Object-oriented Programming.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 17.
Classes Modeling the Object. Objects model the world Classes are programmer defined types that model the parts of a system Class serve as blueprints for.
© 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.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Session 6 Comments on Lab 3 & Implications of Inheritance.
AP Computer Science A – Healdsburg High School 1 Inheritance - What is inheritance? - “Is-a” vs. “Has-a” relationship - Programming example “CircleBug”
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
Objects and Classes Start on Slide 30 for day 2 Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Much of.
COME 339 WEEK 1. Example: The Course Class 2 TestCourceRunCourse.
College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
AP Computer Science A – Healdsburg High School 1 Unit 2 - Structure of a Java Program - Documentation - Types of Errors - Example.
Object-Oriented Programming: Polymorphism Chapter 10.
Chapter 9: Continuing Classes By Matt Hirsch. Table Of Contents 1.Static Fields and Methods 2.Inheritance I. Recycle Code with Inheritance II. Overriding.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
Software Construction Lab 05 Abstraction, Inheritance, and Polymorphism in Java.
An Introduction to Software Development JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin,
 The word static is used to declare either a ________ variable or method.  Why do we use statics?  What is Polymorphism? class In general, we use a.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Sections Inheritance and Abstract Classes
Polymorphism.
Lecture 12 Inheritance.
Objects as a programming concept
One class is an extension of another.
Section 11.1 Class Variables and Methods
One class is an extension of another.
An Example of Inheritance
OOP Aga private institute for computer science 5th grade
Final and Abstract Classes
Classes and Methods 15-Aug-19.
Presentation transcript:

AP Computer Science A – Healdsburg High School 1 Unit 2 - Object-Oriented Programming - Example

AP Computer Science A – Healdsburg High School 2 OOP — Object-Oriented Programming An OOP program models a world of active objects. An object may have its own “memory,” which may contain other objects. An object has a set of methods that can process messages of certain types.

AP Computer Science A – Healdsburg High School 3 OOP (cont’d) A method can change the object’s state, send messages to other objects, and create new objects. An object belongs to a particular class, and the functionality of each object is determined by its class. A programmer creates an OOP application by defining classes.

AP Computer Science A – Healdsburg High School 4 The Main OOP Concepts: Inheritance: a subclass extends a superclass; the objects of a subclass inherit features of the superclass and can redefine them or add new features. Event-driven programs: the program simulates asynchronous handling of events; methods are called automatically in response to events.

AP Computer Science A – Healdsburg High School 5 Inheritance A programmer can define hierarchies of classes More general classes are closer to the top Person ChildAdult BabyToddlerTeen

AP Computer Science A – Healdsburg High School import java.awt.Color; public class Hexagon { public static void main (String [ ] args) { Turtle t; t = new Turtle(); Declare and construct an object of type Turtle. Ex. Using the Turtle class, create a Turtle object and “command” that Turtle object to draw a hexagon with side length 50 pixels.