Chapter 1 Object Orientation: Objects and Classes.

Slides:



Advertisements
Similar presentations
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Advertisements

Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
Objects & Object-Oriented Programming (OOP) CSC 1401: Introduction to Programming with Java Week 15 – Lecture 1 Wanda M. Kunkle.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Chapter 1 Introduction.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
9-Aug-15 Vocabulary. Programming Vocabulary Watch closely, you might even want to take some notes. There’s a short quiz at the end of this presentation!
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
COMP Computer Basics Yi Hong May 13, 2015.
Introducing Java.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
High-Level Programming Languages: C++
CIS Computer Programming Logic
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Introduction to Programming Writing Java Beginning Java Programs.
Java Language and SW Dev’t
Object Oriented Design: Identifying Objects
The Java Programming Language
Introduction to Computer Systems and the Java Programming Language.
1 COS 260 DAY 2 Tony Gauvin. 2 Agenda Questions? Class roll call Blackboard Web Resources Objects and classes 1 st Mini quiz on chap1 terms and concepts.
Classes CS 21a: Introduction to Computing I First Semester,
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Algorithms and Algorithm Analysis The “fun” stuff.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
Working With Objects Tonga Institute of Higher Education.
Week 2 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Introduction to Java Java Translation Program Structure
Introduction to Programming Writing Java Beginning Java Programs.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Working With Objects Tonga Institute of Higher Education.
Salman Marvasti Sharif University of Technology Winter 2015.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
CSH Intro. to Java. The Big Ideas in Computer Science Beyond programming Solving tough problems Creating extensible solutions Teams of “Computational.
Chapter 1 An Overview of Computers and Programming Languages.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CS0007: Introduction to Computer Programming Primitive Data Types and Arithmetic Operations.
CS 1044 Introduction to Programming in C/C++. Hi, My Name is… David McPherson David McPherson 625 McBryde Hall 625 McBryde Hall
Chapter 1 Object Orientation: Objects and Classes.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Programming what is C++
Working with Java.
Introduction to the C Language
Chapter 3 GC 101 Java Fundamentals.
Console Output, Variables, Literals, and Introduction to Type
Introduction to the C Language
Chapter 3 Introduction to Classes, Objects Methods and Strings
Object Oriented Programming in java
Classes CS 21a: Introduction to Computing I
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
Presentation transcript:

Chapter 1 Object Orientation: Objects and Classes

What is Programming? Phases of Programming 1.Design 2.Implementation 3.Testing 4.Repeating

Polya’s Four Step Process Four steps to any problem solving activity 1.Understand the problem 2.Devise a solution 3.Test the solution 4.Rework the solution

Solving Computer Problems Need a tool to solve the problem Use a computer language to do this Different levels of languages * 1.Machine Language 2.Assembly Language 3.High Level Language * Some are talking about 4 th Level Languages

Algorithms What is an algorithm? A finite set of steps that specify a sequence of operations to be carried out in order to solve a specific problem.

Properties of Algorithms 1. Finiteness 2. Absence of Ambiguity 3. Definition of Sequence 4. Feasibility 5. Input 6. Output

What is a Computer? Made up of many independent parts all working together –Memory Unit –Arithmetic/Logic Unit (ALU) –Control Unit –Input Devices –Output Devices –Auxiliary Storage Devices Central Processing Unit (CPU)

Memory Unit Can be thought of to look like a giant grid Each square in the grid is a memory location We can access each location in the grid, if we choose to

Objects and Classes When you create a program using an object-oriented language, you are: –Creating a model of the problem –The model is built up from objects in the problem domain –Those objects must be represented in your program

Object vs. Class The difference between an object and a class is subtle. We will examine a student class. If we wanted to identify one particular student, we would need to ask some questions –What color is his hair? –How tall is he? –What is his QCA?

Object vs. Class In order to answer these questions we need to know what student we are talking about. –This particular student object is an instance of the Student class. In this example, the Student is a class and the instance of the Student is a student object.

Object vs. Class A class is a generic example; a blue print if you will. An object is one particular instance of a class. From one set of blue prints we can make multiple instances. All the instances will be unique but based on the same set of blue prints

Convention Names of Classes start with a Capital Letters. Names of objects start with lower case letters. This case convention is fairly well followed throughout the Java programming community.

BlueJ Example Let’s take a look at an example in BlueJ. All the examples in the notes assume that you have BlueJ installed in C:\BlueJ The Shape Example The Shape Example

Calling Methods When we right clicked on a object on the workbench in BlueJ, we got a popup menu with a bunch of function names listed. In Java, these functions are called methods When we chose one of these methods for the object to perform, we called or invoked the method When the method requires information from the programmer, the method is said to have a parameter

Method Signatures A method signature provides information about the method. –It tells us the name of the method –Whether or not the method requires a parameter –What type of information is returned from the method

Data Types The values a parameter can take Examples –int – whole numbers –String – a section of text Pitfall – forgetting the double quotes around a string. You’ll get a message like “Error: undefined variable”

Java Data Types Java supports two kinds of data types Built-in data types Object data types Built-in data types are types like integers, characters, etc. Object data types are like Strings, Arrays, etc.

Built-in Types Java has a limited amount of built-in types. We will be most concerned with int- For integer numbers double- For floating point numbers boolean- For true/false values char – For character data

Object Types There are many objects types. Some are provided for us The others we will create ourselves. There are some object types we can use with no extra work String – For representing strings of characters System – For some basic output

State All of the attributes that define an object is referred to as the object’s state Java refers to the individual attributes as fields

Multiple Instances Object-oriented programming (OOP) allows for creating more than one object from the same class. The internal state of the object allows the computer to tell the different objects apart.

What is an object? All objects of the same class have the same fields (and methods). The values stored in those fields can be different. Simply being an object of a given class guarantees that the objects will have the same fields

Object Interaction Objects do not normally operate by themselves Objects can create other objects and invoke those object’s methods Most Java programs have objects that will do just this Question: How do we do this?

Source Code Like most programming languages, Java is written using plain text files or source code files The source code tells the program how objects are created and how the objects will interact After a source code file is written, it must be compiled so that the Java Virtual Machine (JVM) can interpret it

Return Values Some methods not only take parameters, but give something back to you. These methods are said to have a return value You can tell this in the signature –String getName() This methods returns a String –void moveRight() This method returns void (nothing)

Homework 1.2, 1.5, 1.6, 1.9, 1.11, 1.18, 1.26

Quiz Explain the difference between an object and a class.