GTECH 731 Lab Session 5 Lab 4 Review, Lab 5 Intro 10/5/10 Lab 4 Review Lab 5 Overview.

Slides:



Advertisements
Similar presentations
OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
Advertisements

Nov 2005 MSc Slide 1 - Another Example of a Structural Pattern Alternative way of adding Functionality to an existing class (alternative to a derived class)
User Interface Programming in C#: Graphics
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Chapter 10: Introduction to Inheritance
Microsoft.NET Fundamentals. Introduction Name Company affiliation Title/function Job responsibility Database & Developer experience Your expectations.
More about classes and objects Classes in Visual Basic.NET.
Object Orientated Concepts. Overview  The world is objects  Defining an object  Not a function, it’s a method  Lets inherit want we can  Objects.
IEG3080 Tutorial 3 Prepared by Ryan. Outline Object Oriented Programming Concepts Encapsulation Inheritance Polymorphism Delegation Course Project.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 Chapter 12 More OOP, Interfaces, and Inner Classes.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
1 Lecture 06(Abstract Classes)Lecture 9 Abstract Classes Overview  Abstract Classes: A Definition.  Declaring Abstract Classes.  Abstract Methods: A.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Object-oriented Programming Concepts
GTECH 731 Lab Session 6 10/12/10 Quiz Review Lab 5 Review Lab 6 Intro.
GTECH 731 Lab Session 8 10/26/10 Lab 7 Geotools. Previous Labs Labs designed to gradually introduce C# and Visual Studio Started with simple, straight.
Chapter 10 Classes Continued
GTECH 731 Lab Session 4 Lab 3 Review, Lab 4 Intro 9/28/10 Lab 3 Review Lab 4 Overview.
GTECH 731 Lab Session 2 Lab 1 Review, Lab 2 Intro 9/6/10 Lab 1 Review Lab 2 Overview.
LECTURE 07 Programming using C# Inheritance
Inheritance using Java
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
Object Oriented Programming: Java Edition By: Samuel Robinson.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Programming using C# for Teachers Introduction to Objects Reference Types Functions of Classes Attributes and Types to a class LECTURE 2.
Inheritance - Polymorphism ITI 1121 Nour El Kadri.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
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.
Abstract Classes. Review PA – 3 Design Considerations /Web/CS239/programs/pa3/draft.php ?harrisnlCS239
C# G 1 CSC 298 Object Oriented Programming Part 2.
© 2000 McGraw-Hill Modified by C.W.Pang with author's permission Intro to OOP with Java--Wu Chapter Chapter 1 Introduction to Object-oriented Programming.
08 Encapsulation and Abstraction. 2 Contents Defining Abstraction Levels of Abstraction Class as Abstraction Defining a Java Class Instantiating a Class.
Introduction to Object-Oriented Programming Lesson 2.
Interfaces and Polymorphism CS 162 (Summer 2009).
CITA 342 Section 1 Object Oriented Programming (OOP)
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
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.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
CSC 205 Programming II Lecture 4 Abstract Class. The abstract keyword indicate that a class is not instantiable Defining a type which will be specialized.
1 DemoBasic_v3, DemoBasic_v4 JButton JLabel. 2 Registering an ActionListener Register by invoking the following from within constructor DemoBasicFrame.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
Comp1004: Object Oriented Design I Abstract Classes and Interfaces.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Modern Programming Tools And Techniques-I
Reference: Object Oriented Design and Programming (Horstmann)
OOP: Encapsulation &Abstraction
Examples of Classes & Objects
Objects as a programming concept
Object Oriented Programming
2.7 Inheritance Types of inheritance
Interface, Subclass, and Abstract Class Review
Interface.
Review Session.
Section 11.1 Class Variables and Methods
ATS Application Programming: Java Programming
Using local variable without initialization is an error.
Java Programming Language
Classes & Objects: Examples
Interfaces.
CSE 1030: Implementing GUI Mark Shtern.
METHOD OVERRIDING in JAVA
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
CSG2H3 Object Oriented Programming
Presentation transcript:

GTECH 731 Lab Session 5 Lab 4 Review, Lab 5 Intro 10/5/10 Lab 4 Review Lab 5 Overview

Lab 4 – OOP OOP combines functions and data into single entity – Object Object defined by Class Variables represent current state of object Methods represent abilities of object Objects modeled through hierarchy of class inheritance Higher abstract level defines general, common characteristics belonging to all subclasses Lower level subclasses define unique characteristics not common to all objects of more abstract class Object is Instance of Class MyCat is instance of Feline namespace MyProjectName { public class Animal { public bool bHeartBeating = true; public void Walk() { // code to implement walk } public class Mammmal : Animal { public bool bWarmBlooded; public void MammalAction() { // code to implement action } public class Feline : Mammmal { public bool bFluffy; public void Feline() { bFluffy = true; } public void Purr() { // code to implement purr } class Program { static void Main(string[] args) { Feline MyCat = new Feline(); MyCat.bFluffy = false; MyCat.Walk(); MyCat.Purr(); MyCat.bWarmBlooded = true; MyCat.bHeartBeating = true; }

Lab 4 – Combining Variables with Methods X1, Y1, X2 and Y2 variables moved into class Line X1, Y1, X2 and Y2 => myLine.X1, myLine.Y1, myLine.X2 and myLine.Y2 X1 = e.X => myLine.X1 = e.X LineLength function copied into class Line Parameter list removed – class variables accessible within class LineLength(X1, Y1, X2, Y2) => myLine.LineLength() Both functions of same name can co-exist; distinguished by parameter list and object association Creating new Line object similar to declaring and initializing variable Line myLine = new Line(); Class “Line” instantiated as Object “myLine” myLine contains endpoint variables and LineLength method

Lab 5 – Object Orientation Moving towards completely self-contained Object Class All methods, including Draw, are within class definition Used Paint handler to “repaint” or redraw the image object e.Graphics.Drawline used outside of object e.Graphics sent into “Draw” method of object private void pbxImage_Paint(object sender, PaintEventArgs e) { // With OOP if (curShape != null) { curShape.Draw(e.Graphics); } private void pbxImage_Paint(object sender, PaintEventArgs e) { // Without OOP e.Graphics.DrawLine(new Pen(Color.Red, 3), myLine.x1, myLine.y1, myLine.x2, myLine.y2); } public override void Draw(Graphics g) { g.DrawLine(new Pen(Color.Red, 2), start.x, start.y, end.x, end.y); }

Lab 5 – Visual Studio Issues Ambiguity using same names “Geometry” namespace and “Geometry” class Point

Lab 5 – Visual Studio Issues Casting curShape as a LineString Object Cannot declare new LineString on every MouseUp event

Lab 5 – Object Overview of Lab 5 – Windows Form Only