1 University of Utah – School of Computing Computer Science 1020 "Object-Oriented Programming"

Slides:



Advertisements
Similar presentations
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Advertisements

Exercise 2.
Notes from HW3 / Lab3 Program documentation – At the top of every class: //************************************************************ // seu01.java Author:
1 University of Utah – School of Computing Computer Science 1021 "Programming with Style"
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 8, 2005.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
COMP 14 Introduction to Programming Miguel A. Otaduy May 25, 2004.
COMP 110 Introduction to Programming Mr. Joshua Stough October 8, 2007.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 8, 2005.
C++ Classes in Depth. Topics Designing Your Own Classes Attributes and Behaviors Writing Classes in C++ Creating and Using Objects.
CS 106 Introduction to Computer Science I 03 / 19 / 2008 Instructor: Michael Eckmann.
COMP 14 Introduction to Programming Miguel A. Otaduy May 24, 2004.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA Prof. Dr. Paulo Brasko Ferreira Fall 2014.
1 University of Utah – School of Computing Computer Science 1021 "Object-Oriented Programming"
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
PERIMETER Definition Add up all sides of the object 2 5 P = P = 14.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
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.
Solving systems of equations with 2 variables
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Procedural and Object-Oriented Programming 13.1.
1 Chapter-01 Introduction to Software Engineering.
PERIMETER Definition Add up all sides of the object 2 5 P = P = 14.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
CS 106 Introduction to Computer Science I 10 / 29 / 2007 Instructor: Michael Eckmann.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Salman Marvasti Sharif University of Technology Winter 2015.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Section 2.4 Graphs of Motion. Why Use Graphs? Show relationships between distance, velocity, acceleration, and time Visual and clear way of representing.
Geometry Formulas Section Formulas  Perimeter of a Triangle:  Area of a rectangle:  Volume of a box:
Coming up: Inheritance
Chapter 8 Functions in Depth. Chapter 8 A programmer-defined function is a block of statements, or a subprogram, that is written to perform a specific.
Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan 3.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 27 I Love this Class.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Functional Abstraction Reduces Complexity.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Starting Out With Java 5 Control Structures to Objects By Tony Gaddis Copyright © 2005, 2005 Pearson Addison-Wesley. All rights reserved. Chapter 6 Slide.
CS 106 Introduction to Computer Science I 03 / 22 / 2010 Instructor: Michael Eckmann.
Classes CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Topics Instance variables, set and get methods Encapsulation
CSCI 51 Introduction to Programming Dr. Joshua Stough February 24, 2009.
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.
COMP Information Hiding and Encapsulation Yi Hong June 03, 2015.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 26, 2009.
Java 5 Class Anatomy. User Defined Classes To this point we’ve been using classes that have been defined in the Java standard class library. Creating.
Modern Database Techniques Part 1: Object Oriented Databases 2. Concepts of Object Oriented Programming Revisited.
For Geometry ( 9th Grade Math )
Classes and OOP.
simplify radical expressions involving addition and subtraction.
Review: Two Programming Paradigms
Class Variables We’ve seen how to add extra subroutines into our programs Can be accessed from within one another We can also add variables that are “global”
Activating Prior Knowledge – Notes
COMP 110 Information hiding and encapsulation
Objective - To identify how perimeter and area relate.
Local Variables, Global Variables and Variable Scope
Objective The student will be able to:
Defining Classes and Methods
2 types of scale factor problems
Defining Classes and Methods
Fundaments of Game Design
Defining Classes and Methods
Adding and Subtracting Radicals
By- Sabrina,Julianna, and Killian
Computer Science II for Majors
Introduction to Computer Science and Object-Oriented Programming
Presentation transcript:

1 University of Utah – School of Computing Computer Science 1020 "Object-Oriented Programming"

University of Utah – School of Computing University of Utah 2 Procedural Programming What we've done so far: -variables -functions that operate on those variables

University of Utah – School of Computing University of Utah 3 Large-Scale Programming Hard to write BIG programs using procedural programming techniques WHY?

University of Utah – School of Computing University of Utah 4 Problem #1 Global Variables!

University of Utah – School of Computing University of Utah 5 Problem #2 Limits of human comprehension

University of Utah – School of Computing University of Utah 6 Problem #3 Brittle dependencies

University of Utah – School of Computing University of Utah 7 Conceptual Leap 1. Dividing a large job into small functions 2. Dividing several large jobs (or concepts) into multiple classes!

University of Utah – School of Computing University of Utah 8 Analogy Toy blocks

University of Utah – School of Computing University of Utah 9 Classes Have variables and functions Or "attributes" and "behaviors"

University of Utah – School of Computing University of Utah Example Consider our geometry program What attributes does a rectangle have?

University of Utah – School of Computing University of Utah Rectangle class class Rectangle { int length; int width; }

University of Utah – School of Computing University of Utah Rectangle class What do you want to do with a rectangle? -Draw it? -Resize it? -Calculate area? -Calculate perimeter?

University of Utah – School of Computing University of Utah Methods class Rectangle { int width; int height; void draw() { //do stuff } double computePerimeter() { //do stuff } };

University of Utah – School of Computing University of Utah How to draw a rectangle? void draw() { }

University of Utah – School of Computing University of Utah How to find a rectangle's perimeter? double computePerimeter() { }

University of Utah – School of Computing University of Utah Classes vs. Objects A class is just the "definition" or the code An object is when you make a variable whose type is a class Example: - Rectangle r;

University of Utah – School of Computing University of Utah Block example revisited Wrap up all attributes and methods inside a class Easier to manage! Safer too? Why?

University of Utah – School of Computing University of Utah Car example You can drive a car without knowing how it works internally "public" user interface: -steering wheel -gas/brake pedals -ignition

University of Utah – School of Computing University of Utah Car example You can drive a car without knowing how it works internally "private" inner workings -don't know, don't care

University of Utah – School of Computing University of Utah "public" explained public methods and variables -Other classes can use them A struct's variables are public by default.

University of Utah – School of Computing University of Utah "private" also! private methods and variables -Other classes may NOT access them Used for internal data By default, everything in a class is private

University of Utah – School of Computing University of Utah A General Rule private variables -they are our internal data public methods -they are how other classes use our class

University of Utah – School of Computing University of Utah Rectangle class revisited class Rectangle { private: int width; int height; public: void draw() { //do stuff } double computePerimeter() { //do stuff }

University of Utah – School of Computing University of Utah Why public and private? Secrecy? No. Simplicity? Yes. Order? Yes. Maintainability? Yes.

University of Utah – School of Computing University of Utah Examples Math.random() JPanel.add()

University of Utah – School of Computing University of Utah Reminder Homework 5 is due tomorrow

University of Utah – School of Computing University of Utah Request for Comments Please fill out online survey!