Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Object Oriented Concepts 2 Stewart Blakeway FML 213

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Processing Lecture. 1 What is processing?
PHY-102 SAPIntroductory GraphicsSlide 1 Introductory Graphics In this section we will learn how about how to draw graphics on the screen in Java:  Drawing.
Applets Graphical Java programs Run inside web browser Platform-neutral Easy deployment--loads when needed Secure.
Object Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
Processing Processing is a simple programming environment that was created to make it easier to develop visually oriented applications with an emphasis.
Lecture 28: Abstract Classes & Inheritance Announcements & Review Lab 8 Due Thursday Image and color effects with 2D arrays Read: –Chapter 9 Cahoon & Davidson.
Faculty of Sciences and Social Sciences HOPE Variables and Trace Tables Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 8: Java: Selection and Repetition Stewart Blakeway.
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Object Oriented Concepts 3 Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE Object Oriented Programming Pie Eater Revisited Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE Java: Loops within loops Stewart Blakeway FML 213
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving An Introduction Stewart Blakeway
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Fall 2007ACS-1903 BlueJ Ron McFadyen Lab 1: Using BlueJ at UofW The purpose of this lab is to give you some experience with BlueJ. Over the course of the.
HST 952 Computing for Biomedical Scientists Lecture 2.
CSC 160 Computer Programming for Non-Majors Lecture #3c: Working with Pictures (continued) Prof. Adam M. Wittenstein
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
A Simple Applet.
CS288 Lab Exercise 1. UniS Open PersonGui Files Go to Course web site for PersonGui source files
Java: Chapter 1 Computer Systems Computer Programming II Aug
1 CSC 221: Computer Programming I Fall 2004 Objects and classes: a first pass  software objects, classes, object-oriented design  BlueJ IDE, compilation.
Object Oriented Software Development
From BlueJ to NetBeans SWC 2.semester.
CS1101: Programming Methodology
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
Faculty of Sciences and Social Sciences HOPE JavaScript Validation Regular Expression Stewart Blakeway FML
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
Java: Chapter 1 Computer Systems Computer Programming II.
Introduction to Programming with Java. Overview What are the tools we are using – What is Java? This is the language that you use to write your program.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
Greenfoot. Getting Started Open the Greenfoot download site: Select Greenfoot
1 CSC 221: Computer Programming I Spring 2010 Objects and classes: a broad view  Scratch programming review  object-oriented design, software objects.
CPSC150 Spring 2007 Dr. L. Lambert. CPSC150 Overview Syllabus Use Textbook, ask questions, extra thorough, I will post sections covered All information.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Introduction to Java. 2 Textbook David J. Barnes & Michael Kölling Objects First with Java A Practical Introduction using BlueJ Fourth edition, Pearson.
OBJECTS AND CLASSES CITS1001. Concepts for this lecture class; object; instance method; parameter; signature data type multiple instances; state method.
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.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Chapter 1 Object Orientation: Objects and Classes.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
1 CSC 221: Computer Programming I Spring 2008 Objects and classes: a broad view  software objects, classes, object-oriented design  BlueJ IDE, compilation.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02b: Tutorial for Programming in Processing Jarek Rossignac.
1 CSC 222: Object-Oriented Programming Spring 2013 Objects and classes: a first pass  221 review  software objects, classes, object-oriented design 
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
1 A Simple Applet. 2 Applets and applications An applet is a Java program that runs on a web page Applets can be run within any modern browser To run.
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.
1 CSC 221: Computer Programming I Fall 2009 Objects and classes: a broad view  Scratch programming review  object-oriented design, software objects 
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.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
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.
Object Oriented Programming Lecture 3: Things OO.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 1 1 Introduction to Java. 2 History of Java Java – Originally for intelligent consumer-electronic devices – Then used for creating Web pages with dynamic.
Introducing Scratch Learning resources for the implementation of the scenario
Chapter 1 Object Orientation: Objects and Classes.
Objects as a programming concept
CSC 222: Object-Oriented Programming
CSC 222: Object-Oriented Programming
Java Programming with BlueJ
Java Methods Objects and Classes Start on Slide 30 for day 2
Announcements & Review
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Java Programming with BlueJ Objectives
Lecture 1 Introduction to Software Construction
Presentation transcript:

Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Object Oriented Concepts 2 Stewart Blakeway FML 213

Faculty of Sciences and Social Sciences HOPE What we did in OO Lecture 1 Defined objects and classes Objects are instances of classes Objects encapsulate (or contain) – State (data or attribute values) – A protocol (a set of functions, messages, methods etc ) (also known as an interface) 2

Faculty of Sciences and Social Sciences HOPE What we did in OO Lecture 1 Objects send and receive messages in the form : (Object “DOT” message) – Object. message (with/without parameters) – textBlock1.setFont(“Courier New”); Using a message and its signature: – Return type (Answer type) – Message name – Parameters (List of data items sent with the message) 3

Faculty of Sciences and Social Sciences HOPE What we did in OO Lecture 1 Identifying attributes (state of the Object) and protocols Representing objects using object diagrams. Sending messages to an object in Java 4

Faculty of Sciences and Social Sciences HOPE Quizlet What is the only way we can change the state of an object? Sending it a message What is the collection of messages that an object can understand called? Protocol 5

Faculty of Sciences and Social Sciences HOPE Quizlet int getAge() What is the message name? getAge What type of thing is returned by the message? int How many items in the parameter list? None 6

Faculty of Sciences and Social Sciences HOPE Quizlet Triangle1.moveHorizontal(60) What is the name of the object receiving the message? Triangle1 What is the name of the message? moveHorizontal What parameter does the message have? 60 7

Faculty of Sciences and Social Sciences HOPE What we shall do today Introduce Java as an Object oriented language Installing and running BlueJ Ver on a PC ( Creating objects, sending messages and Object states in BlueJ environment Chapter 9 up to 9.7 in Data Structures to Java booklet 8

Faculty of Sciences and Social Sciences HOPE BlueJ Screen 9

Faculty of Sciences and Social Sciences HOPE Geeting the BlueJ Projects You will find the BlueJ projects on the course website… … seminar Download and unzip it 10

Faculty of Sciences and Social Sciences HOPE BlueJ Environment 11 Start BlueJ, Open Project named hopeshapes

Faculty of Sciences and Social Sciences HOPE BlueJ Environment 12 Start BlueJ, Open Project named hopeshapes Each brown box represents a class

Faculty of Sciences and Social Sciences HOPE BlueJ Environment 13 Start BlueJ, Open Project named hopeshapes Make an object of a class by right clicking on its brown box and selecting menu item new () e.g. new Triangle()

Faculty of Sciences and Social Sciences HOPE Creating Objects Every brown rectangle symbol represents a class Compile by right-clicking on a class and then selecting pop-up menu item Compile Create a Triangle object by right-clicking on the Triangle rectangle and select: – new Triangle() 14

Faculty of Sciences and Social Sciences HOPE Creating Objects using the new message 15 The new message helps to construct a Triangle software object triangle1

Faculty of Sciences and Social Sciences HOPE Creating a Triangle object 16 A red Triangle software object triangle1 appears at the bottom left corner

Faculty of Sciences and Social Sciences HOPE Creating many objects 17 More Red objects appear. How many objects of each class?

Faculty of Sciences and Social Sciences HOPE Creating many objects 18 Send them messages to see their behaviour

Faculty of Sciences and Social Sciences HOPE Simple messages to object triangle1 Send a message makeVisible() to triangle1 to see it BY RIGHT – CLICKING on the triangle1 object 19

Faculty of Sciences and Social Sciences HOPE Display Window The triangle1 object appears with default state values set in the constructor message Triangle() 20 height = 30; width = 40; xPosition = 50; yPosition = 15; color = "green"; isVisible = true;

Faculty of Sciences and Social Sciences HOPE Sending Messages with parameters To move the green triangle1 object 50 pixels to the right, we use moveHorizontal (50) 21 Message signature

Faculty of Sciences and Social Sciences HOPE Sending Messages with parameters To move the green triangle1 object 50 pixels to the right, we use moveHorizontal (50) 22 Void return Parameter, integer Integer Value 50 Method name

Faculty of Sciences and Social Sciences HOPE Sending message = Method call To change colour of the triangle1 object to blue, we call changeColor (“blue”) Notice the quotes “” for a String parameter 23

Faculty of Sciences and Social Sciences HOPE Displaying the state of an object Pick an object in the Menu of objects, Right- click and choose Inspect 24 The Inspect menu item

Faculty of Sciences and Social Sciences HOPE Current state of triangle1 object 25

Faculty of Sciences and Social Sciences HOPE Different states of the same object 26 Circle int diameter int xPosition int yPosition String color Boolean isVisible Is instance of

Faculty of Sciences and Social Sciences HOPE Drawing Pictures 27 By creating many objects, we can draw many shapes - A house with chimney !

Faculty of Sciences and Social Sciences HOPE Editing the source code 28 Open the hopepicture project

Faculty of Sciences and Social Sciences HOPE Editing source code 29 Opening the editor with Picture class selected to see the class source code

Faculty of Sciences and Social Sciences HOPE Source Code – explore the code! 30

Faculty of Sciences and Social Sciences HOPE Things to remember Go to BlueJ web site: – – Click on download at left – Get and install the Java by clicking on JDK 6 on the right – Get and install BlueJ by clicking on bluejsetup-254.exe 31