Programming with Objects Object Interaction (Part 1) Week 9.

Slides:



Advertisements
Similar presentations
Looking inside classes Fields, Constructors & Methods Week 3.
Advertisements

More Sophisticated Behaviour 1 Using library classes to implement more advanced functionality.
Introduction to Programming Lecture 39. Copy Constructor.
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
Divisibility Rules Page 10 in textbook.
Chapter 8 Data Analysis. Agenda Functions –AND and OR –COUNT, COUNTA, and COUNTIF –CONCATENATE and TRIM –RANK and QUARTILE –MOD and ROW Goal Seek in decision-making.
Looking inside classes Choices Week 4. Class bodies contain fields, constructors and methods. Fields store values that determine an object’s state. Constructors.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Understanding class definitions Looking inside classes 3.0.
More sophisticated behavior Using library classes to implement some more advanced functionality 4.0.
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 – Part 2 Wanda M. Kunkle.
Object interaction Creating cooperating objects 3.0.
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.
Programming with Objects Creating Cooperating Objects Week 6.
Object Interaction 1 Creating cooperating objects.
Object interaction Creating cooperating objects 5.0.
Object interaction Creating cooperating objects 5.0.
Introduction to Programming. To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically.
Programming with Collections Grouping & Looping - Collections and Iteration Week 7.
Object Interaction 2 Creating cooperating objects.
Object interaction Creating cooperating objects. 28/10/2004Lecture 3: Object Interaction2 Main concepts to be covered Abstraction Modularization Class.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
1 Web Based Programming Section 6 James King 12 August 2003.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 6 Introduction to classes and objects.
Java Class Syntax CSIS 3701: Advanced Object Oriented Programming.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
Programming Fundamentals 2: Interaction/ F II Objectives – –introduce modularization and abstraction – –explain how an object uses other.
CSE 113 Introduction to Computer Programming Lecture slides for Week 5 Monday, September 26 th, 2011 Instructor: Scott Settembre.
Classes CS 21a: Introduction to Computing I First Semester,
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
OBJECT INTERACTION CITS1001. Overview Coupling and Cohesion Internal/external method calls null objects Chaining method calls Class constants Class variables.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
CSC 107 – Programming For Science. The Week’s Goal.
Java Programming The Language of Now & the Future* Lecture 0 An Introduction to Java Syntax for Non-C Programmers John Morris Department of Electrical.
COS 260 DAY 5 Tony Gauvin.
"Give a person a fish and you feed them for a day; teach that person to use the Internet and they won't bother you for weeks.“ --unknown "Treat your password.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Chapter 3 Object Interaction.  To construct interesting applications it is not enough to build individual objects  Objects must be combined so they.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
Arithmetic, Class Variables and Class Methods Week 11
1 Opbygning af en Java klasse Abstraktion og modularisering Object interaktion Introduktion til Eclipse Java kursus dag 2.
1.Reading from Keyboard 2.Main programs 3.Responsibilities 1 CS12230 Introduction to Programming Lecture 2or3-Other things.
Introduction to Programming Lecture 4. Key Words of C main main if if else else while while do do for for.
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.
Objects First With Java A Practical Introduction Using BlueJ Casting Week
Looking inside classes Conditional Statements Week 4.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
Collections and Iteration Week 13.  Collections  ArrayList objects  Using loops with collections Collections and Iteration CONCEPTS COVERED THIS WEEK.
Lecture 3: More on Classes Textbook: Chapter 2 Recap: –Classes vs. Objects –Q: What comes first a class or an object? –Q: Do we need a class to create.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
More Sophisticated Behavior
Objects and Classes CITS1001 week 1.
Objects First with Java Creating cooperating objects
Object INTERACTION CITS1001 week 3.
CLASS DEFINITION (> 1 CONSTRUCTOR)
Chapter 10 Thinking in Objects
Introduction to Java Programming
COS 260 DAY 16 Tony Gauvin.
Week 4 Object-based Programming (2) Classes and Objects: A Deeper Look
Creating cooperating objects
Creating cooperating objects
Objects First with Java Creating cooperating objects
Week 4 Lecture-2 Chapter 6 (Methods).
Objects First with Java Creating cooperating objects
F II 4. Object Interaction Objectives
Classes CS 21a: Introduction to Computing I
COS 260 DAY 6 Tony Gauvin.
Day 11 The Last Week!.
Presentation transcript:

Programming with Objects Object Interaction (Part 1) Week 9

Abstraction & modularisation The modulo operator Programming with Objects CONCEPTS COVERED THIS WEEK

Abstraction is the ability to ignore details of parts to focus attention on a higher level of a problem. Modularisation is the process of dividing a whole into a set of well-defined parts, where each part can be built and tested separately, and where each part only interacts with other parts in well-defined ways. Programming with Objects ABSTRACTION & MODULARISATION

It is an object that is made up of other objects! Wheels, Seats, Chassis, Exhaust, Steering Wheel, etc. This car is a Complex Object And… a wheel itself is also a complex object! Tyre, Trim, Hub Cap, etc. ABSTRACTION Object Model

MODULARISATION Object Model Team 1 works on producing the Engine Design: Team 2 works on producing the Seat Design: Team 3 works on producing the Wheel Design: Team 3a works on producing the Tyre Design:

Programming with Objects ABSTRACTION & MODULARISATION A digital clock

Programming with Objects ABSTRACTION & MODULARISATION Modularising the clock display One four-digit display? Or two two-digit displays?

BlueJ Demonstration A look at the NumberDisplay class

Programming with Objects Source Code - NumberDisplay public class NumberDisplay { private int limit; private int value; // Constructor and methods // omitted. }

Programming with Objects Source Code - NumberDisplay public NumberDisplay(int rollOverLimit) { limit = rollOverLimit; value = 0; } public int getValue() { return value; }

Programming with Objects Source Code - NumberDisplay public String getDisplayValue() { if(value < 10) { return "0" + value; } else { return "" + value; }

Programming with Objects Source Code - NumberDisplay public void setValue(int replacementValue) { if((replacementValue >= 0) && (replacementValue < limit)) { value = replacementValue; }

Modulo (or modulus or mod) operator The % operator gives the remainder of a division result = 10 % 3; assigns a value of 1 to result result = 15 % 6; result = 19 % 11;

Programming with Objects Source Code - NumberDisplay public void increment() { value = (value + 1) % limit; }

Required Reading Objects First With Java – A Practical Introduction using BlueJ Related reading for this lecture Chapter 3