308-203A Introduction to Computing II Lecture 4: Visual Programming A Case Study of OOP Fall Session 2000.

Slides:



Advertisements
Similar presentations
Written by: Dr. JJ Shepherd
Advertisements

AbstractClassesInterfacesPolymorphism1 Abstract Classes, Interfaces, Polymorphism Barb Ericson Georgia Tech April 2010.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Chapter 8 Inheritance Part 2. © 2004 Pearson Addison-Wesley. All rights reserved8-2 Outline Creating Subclasses Overriding Methods Class Hierarchies Inheritance.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
1 Lecture 06(Abstract Classes)Lecture 9 Abstract Classes Overview  Abstract Classes: A Definition.  Declaring Abstract Classes.  Abstract Methods: A.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 11 / 15 / 2006 Instructor: Michael Eckmann.
Unit 9 1 Unit 9: Enhanced class design H In this unit: Abstract classes Packages basic programming concepts object oriented programming topics in computer.
Review CSC 171 FALL 2004 LECTURE 21. Topics Objects and Classes Fundamental Types Graphics and Applets Decisions Iteration Designing Classes Testing and.
1 Topic 10 Abstract Classes “I prefer Agassiz in the abstract, rather than in the concrete.”
CSCI-383 Object-Oriented Programming & Design Lecture 15.
Options for User Input Options for getting information from the user –Write event-driven code Con: requires a significant amount of new code to set-up.
MIT AITI 2003 Lecture 7 Class and Object - Part I.
Event Handling in Java: Alternatives and Patterns Raja Sooriamurthi Information Systems Department Kelley School of Business Indiana.
Inheritance using Java
MIT AITI 2002 Abstract Classes, Interfaces. Abstract Classes What is an abstract class? An abstract class is a class in which one or more methods is declared,
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Session 12 Introduction to PinBallGame (Chaper 7).
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
The Java Inheritance Hierarchy CSIS 3701: Advanced Object Oriented Programming.
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
CS 11 java track: lecture 4 This week: arrays interfaces listener classes inner classes GUI callbacks.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Final Review Lecture 14.
Dependency Injection Technion – Institute of Technology Author: Gal Lalouche - Technion 2015 ©
1 Abstract Classes “I prefer Agassiz in the abstract, rather than in the concrete.” CS Computer Science II.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Introduction to Web Services. Examples Using a Web Service Creating a new Web Service.
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
Session 19 Chapter 10 – Mechanisms for Software Reuse.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Session 13 Pinball Game Construction Kit (Version 3):
May 12, 1998CS102-01Lecture 7-3 Building GUIs in Java I CS Lecture 7-3 A picture's worth a thousand words.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Salman Marvasti Sharif University of Technology Winter 2015.
Lesson 3: Arrays and Loops. Arrays Arrays are like collections of variables Picture mailboxes all lined up in a row, or storage holes in a shelf – You.
ITIP © Ron Poet Lecture 14 1 Responsibilities. ITIP © Ron Poet Lecture 14 2 Two Sections of Code  If we ask two people to work together to do a job,
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.
Written by: Dr. JJ Shepherd
CHAPTER 7 Object Oriented Programming. Object-oriented program “Data and Operations go together was independently” is the main idea The promise of making.
CompSci Reading from Files  import java.io.File;  Declare a file File fileOfCats = new File(”cats.txt”);  Use file – pass it as an argument to.
CSC 142 F 1 CSC 142 References and Primitives. CSC 142 F 2 Review: references and primitives  Reference: the name of an object. The type of the object.
Object Oriented Programming in C++ Chapter 7 Dynamic Binding.
Object-Oriented Programming Fundamentals. Comp 241, Fall Example Colored points on the screen What data goes into making one? Coordinates Color.
Java Input and Output. Java Input  Input is any information needed by your program to complete its execution  So far we have been using InputBox for.
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
A Introduction to Computing II Lecture 3: Interfaces and Inheritance Fall Session 2000.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
CS 116 Object Oriented Programming II Lecture 9 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit7: Event-driven programming 1.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
Web Design & Development Lecture 9
Building Java Programs
Winter 2018 CMPE212 9/21/2018 CMPE212 – Stuff…
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
Week 6 Object-Oriented Programming (2): Polymorphism
Topic 10 Abstract Classes “I prefer Agassiz in the abstract,
Topic 10 Abstract Classes “I prefer Agassiz in the abstract,
Object-Oriented Programming: Inheritance and Polymorphism
CISC124 Assignment 3 sample solution will be posted tonight after 7pm.
CSC 111 Exam 3 Review Fall 2005.
CS2013 Lecture 7 John Hurley Cal State LA.
Expanding the PinBallGame
A picture's worth a thousand words
Presentation transcript:

A Introduction to Computing II Lecture 4: Visual Programming A Case Study of OOP Fall Session 2000

What is Visual Programming? Desktop Window Start Answer: Just the point-and-click we know-and-love

A good example of OOP Windows, dialogs and all the other little boxes can be clearly visualized as individual objects with their own private instance data They share many behaviors, so code can be reused if it is arranged to leverage inheritance

A Simplified Case-Study Text-based: just arrays of char Simple visual hierarchy: just windows on a desktop (no mouse-clicks) We will implement one from scratch:

A Simplified Case-Study ******** *Win 1 * * ***+Win … “Desktop” with two windows

Helper Class “Coordinate” class Coordinate { Coordinate(int x, int y) { … } int getX( ) {…} ; int getY( ) {…}; } To draw text at certain x-y coordinates, it will be handy to package up those coordinates:

The Class Hierarchy DrawingAreaVector (JDK) EmbeddedDrawingArea ConcreteDrawingArea Screen Desktop Window TextWindow DrawableVector Coordinate

Abstraction of “Drawing” Drawable - things which can be drawn (the “painting”) DrawingArea - where things can be drawn (the “canvas” ) DrawingAreas will provide methods so that Drawable things can draw themselves.

Abstraction of “Drawing” Drawable - things which can be drawn (the “painting”) DrawingArea - where things can be drawn (the “canvas” ) interface Drawable { void draw( ); }

Abstraction of “Drawing” Drawable - things which can be drawn (the “painting”) DrawingArea - where things can be drawn (the “canvas” ) abstract class DrawingArea { void drawCharAt(Coordinate, char); char getCharAt(Coordinate); boolean checkValid(Coordinate) {…}; }

Making it more Concrete class ConcreteDrawingArea extends DrawingArea { char [] [] myData; void drawCharAt(Coordinate, char) { … } char getCharAt(Coordinate) { … } }

So what’s the difference? ConcreteDrawingAreas have real text data ConcreteDrawingAreas provide methods to access that data which were prescribed but not implemented in DrawingArea Note: even a ConcreteDrawingArea is little more than a stylized array of char

Screen Problem: We still can’t actually print anything… Solution: Add a class with more functionality class Screen extends ConcreteDrawingArea { // This just calls System.out.println void dump( ) { … } }

Desktop Problem: screens only remember character data and print it out… they don’t know about windows and things class Desktop extends Screen { addItem(Drawable); removeItem(Drawable); bringToFront(Drawable); }

Desktop is “Drawable,” too class Desktop extends Screen { void draw( ) { // for each Drawable thing, d, on the Desktop d.draw( ); }

DrawableVector The above is neatly handled by extending the JDK class Vector so that it is Drawable… To draw yourself, just draw each element in order.

The Class Hierarchy (so far) DrawingAreaVector (JDK) ConcreteDrawingArea Screen Desktop DrawableVector Coordinate

Any questions?

So what Drawables do we put on the Desktop? It’s time for windows, dialogs, and such: the stuff of point-and-click…

Embedded Drawing Areas Problem: Windows and dialogs and such need to move around easily and transparently. Desktop Window Start Window (0,0)

Embedded Drawing Areas Problem: Windows and dialogs and such need to move around easily and transparently. Desktop Window Start Window (0,0) has moved

Embedded Drawing Areas Solution: Remember offset inside another drawing area. Desktop Window Start Embedded area Embedding area

Embedded Drawing Areas class EmbeddedDrawingArea extends ConcreteDrawingArea { int x_offset, y_offset; DrawingArea embedding; void moveTo(x,y); }

Window Problem: We can’t see where a window ends and the desktop begins. Solution: Add a border.

Window class Window extends EmbeddedDrawingArea { char border; drawBorder( ) { // new method } drawCharAt( ) { // OVERRIDE } draw( ) { // OVERRIDE } }

TextWindow class TextWindow extends Window { String text; void setText(String); draw( ) { // OVERRIDE } }

The Class Hierarchy DrawingAreaVector (JDK) EmbeddedDrawingArea ConcreteDrawingArea Screen Desktop Window TextWindow DrawableVector Coordinate

Any questions?