Learning to Program with C# - 41 Unit 4 Examine the structure of the solutionExamine the structure of the solution –classes/methods. Who calls what? How.

Slides:



Advertisements
Similar presentations
Microsoft ® Office 2007 Overview Get up to speed with the 2007 system Leon County Schools presents:
Advertisements

Office 2003 Introductory Concepts and Techniques M i c r o s o f t Windows XP Project An Introduction to Microsoft Windows XP and Office 2003.
Introduction to the SPL Interpreter
User Friendly Price Book Maintenance A Family of Enhancements For iSeries 400 DMAS from Copyright I/O International, 2006, 2007, 2008, 2010 Skip Intro.
Microsoft ® Office Training Get up to speed with the 2007 system presents:
Master Chef 2.08 Take out / Delivery Master Chef will ask you for user ID.
Click Here to Begin. 1. The candle is _______ the present. on between over under.
Computer Basics Hit List of Items to Talk About ● What and when to use left, right, middle, double and triple click? What and when to use left, right,
Code Composer Department of Electrical and Computer Engineering
Unit 3 Day 4 FOCS – Web Design. No Journal Entry.
Unit 3 Day 5 FOCS – Web Design. Unit #3 Entry #3 What is the difference between an inline tag and a block tag? Give an example of both.
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
Presentation Title Your Name Organisation and Telephone Number.
Calendar Browser is a groupware used for booking all kinds of resources within an organization. Calendar Browser is installed on a file server and in a.
IEG 3080 Tutorial 1 Wilson Ip. Outline Lecture reviews: Some basics of Software Engineering principle Some basics of OOP How to use Visual Studio.NET.
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Word Create footnotes and endnotes. Course contents Overview: Be a footnote and endnote whiz Lesson 1: Add footnotes and endnotes Lesson 2: Beyond the.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Introduction to VB.NET Tonga Institute of Higher Education.
Microsoft ® Office 2007 Get up to speed with the 2007 system Murray State University College of Education:
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Learning to Program with C# - 21 Unit 2 Explore a problem in detailExplore a problem in detail –See how it can be modelled Introduce the first set of fundamental.
1 Workshop 4 (B): Visual Basic Test Project Mahidol University June 13, 2008 Paul Evenson University of Delaware Bartol Research Institute.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
IE 411/511: Visual Programming for Industrial Applications
Intro to C++. Getting Started with Microsoft Visual Studios Open Microsoft Visual Studios 2010 Click on file Click on New Project Choose Visual C++ on.
Learning to Program with C# - 31 Unit 3 Introduction to Visual StudioIntroduction to Visual Studio Examine the Rocket problem modelled in C#Examine the.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
Creating a Project with C++ Builder
Teacher’s Assessment Assistant Worksheet Builder Starting the Program
Microsoft ® Office Training Get up to speed with the 2007 system.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Active-HDL Interfaces Debugging C Code Course 10.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
***Adding items to your Etudes Homepage*** Log into Etudes
Chapter 3 The Visual Basic Editor. Important Features of the VBE Alt-F11 will open the Visual Basic Editor. The Code window is to the right, Project Explorer.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
Lesson 2: Manipulating Text Courseware #: 3240
Object Oriented Software Development
1 Object-Oriented Programming (Java), Unit 24 Stand In Final Project Description Kirk Scott.
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
FrontPage Tutorial Part 2 Creating a Course Web Site.
Preset and custom animation
The Object Model. You can think of the contents of an Excel application as a hierarchy of collections of objects, manipulated by code Each object can.
Development with Eclipse Software Engineering Prof. Werner Krandick.
M1G Introduction to Programming 2 5. Completing the program.
Introduction to OOP in VB.NET using Robots ACSE Conference, Nov 2004 Michael Devoy Monsignor Doyle C.S.S., Cambridge
Learning to Program with C# - 41 Unit 5 Adding behaviour using inheritanceAdding behaviour using inheritance Introducing polymorphismIntroducing polymorphism.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Computer Basics Tutorial Text boxes like this will give you information. Boxes like this at the bottom of a slide will give you instructions. Press the.
Creating Web Pages with Links, Images, and Embedded Style Sheets
Intro to. Windows – Mac – osx
© Execview Ltd 2015: all rights reserved Execview Scorecard Training/Reference Guide 2013 Key functions guide for Scorecard administrators.
Chapter 14 Windows Programming with the Microsoft Foundation Classes
Development with Eclipse
Scratch for Interactivity
Chapter 1: An Introduction to Visual Basic 2015
Object-Oriented Programming: Inheritance and Polymorphism
Introduction to Object-Oriented Programming in Alice
Running a Java Program using Blue Jay.
Welcome To Microsoft Word 2016
Presentation transcript:

Learning to Program with C# - 41 Unit 4 Examine the structure of the solutionExamine the structure of the solution –classes/methods. Who calls what? How does it work? Show how ExecuteMission and Rocket/Arena fit into all of this. Motivate the introduction of new behaviours without throwing away the oldMotivate the introduction of new behaviours without throwing away the old Introduce inheritanceIntroduce inheritance Show it happening in the Rocket example, and get some practiceShow it happening in the Rocket example, and get some practice

Learning to Program with C# - 42 Examing the Rocket project Three major classesThree major classes –RocketController –Rocket –Arena and one to get it all goingand one to get it all going –ExecuteMission Creates an arena objectCreates an arena object Creates a rocket object, passing it the arena to fly inCreates a rocket object, passing it the arena to fly in Creates a rocket controller, passing it both the rocket and arenaCreates a rocket controller, passing it both the rocket and arena Instructs the rocket controller to start the mission – FlyInstructs the rocket controller to start the mission – Fly –No objects are created by this class – not a factory one method – Main – the starting point for the whole programone method – Main – the starting point for the whole program

Learning to Program with C# - 43 A new kind of controller… Say we are happy with the flight executed by the controller…Say we are happy with the flight executed by the controller… –but, we now want to try a different flight, –and keep the old flight also Note the general case hereNote the general case here –A: We want to keep the old behaviour –B: We want to keep all else the same just make an adjustment to the flight instructionsjust make an adjustment to the flight instructions

Learning to Program with C# - 44 Concept: Inheritance We want to minimise the work involved in building our new controllerWe want to minimise the work involved in building our new controller –we want to inherit as much of the old controller's structure as possible –only creating anew that which we want changed Inheritance – a core concept in the object- oriented programming modelInheritance – a core concept in the object- oriented programming model –a key feature of large systems building –if we have an item, and we want a new, related, item, we have to build only that part which is different, reusing unchanged parts –we build families of related classes/objects

Learning to Program with C# - 45 Changing or adding behaviour Here, we are proposing to change an existing behaviourHere, we are proposing to change an existing behaviour We could also use the inheritance concept to add new behaviourWe could also use the inheritance concept to add new behaviour –add methods –for example, add an AutoLand method to the rocket controller –we will examine this style later

Learning to Program with C# - 46 Analogy – a car engine factory –these often have an engine management chip in them, controlling how the engine runs –in the factory, we can arrange to have one kind of chip put into some cars and another kind put into other cars we do not build a whole new engine plantwe do not build a whole new engine plant we can pick alternate behaviourswe can pick alternate behaviours in effect we have two factories, in that two kinds of engines are produced – but almost all the technology is shared and reusedin effect we have two factories, in that two kinds of engines are produced – but almost all the technology is shared and reused

Learning to Program with C# - 47 Let's see this in action: –Using the Object Browser, click on the + next to RocketController keep pressing the +s until you get no morekeep pressing the +s until you get no more –Do the same on + next to LoopingFlight RocketController inherits from Object – this is a root class for ALL classes, containing behaviour common to all classesRocketController inherits from Object – this is a root class for ALL classes, containing behaviour common to all classes M

Learning to Program with C# - 48 The LoopingFlight Class Click on LoopingFlight in the Obj BrowserClick on LoopingFlight in the Obj Browser –In members window, there's only two members LoopingFlight – a constructor methodLoopingFlight – a constructor method Fly – the new version of Rocket Controller's FlyFly – the new version of Rocket Controller's Fly –Compare this with RocketController there are additional members for the Rocket and the Arena that are being controlled, of which the controller must keep trackthere are additional members for the Rocket and the Arena that are being controlled, of which the controller must keep track there is no need to re-specify these in LoopingFlightthere is no need to re-specify these in LoopingFlight

Learning to Program with C# - 49 Running the LoopingFlight controller… –we are executing a different kind of mission –so, in the Object Browser, double click on ExecuteMission to open its code window down near the bottom, you'll see the codedown near the bottom, you'll see the code RocketController RC = new RocketController( rArena,… change new RocketController to new LoopingFlightchange new RocketController to new LoopingFlight you are simply telling the system to use a different kind of controller to fly the rocketyou are simply telling the system to use a different kind of controller to fly the rocket everything else stays the sameeverything else stays the same now choose Start from the Debug menu as beforenow choose Start from the Debug menu as before

Learning to Program with C# Create your own controller Choose a flight style, ballistic missile perhaps…Choose a flight style, ballistic missile perhaps… –takes off, flies left, then down nose-first into the ground We need a new class in the project, inheriting from RocketControllerWe need a new class in the project, inheriting from RocketController –choose menu item Project/Add Class –select the Template Code File –type a class name – say BallisticFlight.cs – then Enter –open LoopingFlight and select and copy all the text in it –paste it into the empty BallisticFlight window –change occurrences of LoopingFlight to BallisticFlight –adjust the comment in green to describe this flight –adjust ExecuteMission so that BallisticFlight is used –Debug/Start to see if it all works!!

Learning to Program with C# Important terminology LoopingFlight is a derived class, inheriting from RocketControllerLoopingFlight is a derived class, inheriting from RocketController RocketController is a base class of LoopingFlightRocketController is a base class of LoopingFlight The Fly method of LoopingFlight overrides the Fly method of RocketControllerThe Fly method of LoopingFlight overrides the Fly method of RocketController In the code for RocketControllerIn the code for RocketController –Fly is marked as a virtual method. This indicates that it can be overriden in the way we want in an inherited class In the code for LoopingFlightIn the code for LoopingFlight –The inheritance relationship is made clear in the first line of the class specification public class LoopingFlight : RocketController etc etc –Fly is marked override to show it is overriding the base Fly

Learning to Program with C# Look around the code files… Start to see the patterns that repeat themselvesStart to see the patterns that repeat themselves –how is a class specified –how is each method specified Pick up the general structurePick up the general structure –we will address specifics as the course progresses –eventually, a text book will help you out

Learning to Program with C# Summary Introduced the concept of inheritanceIntroduced the concept of inheritance –developing new classes that are related to existing classes at minimum cost Specifically, this timeSpecifically, this time –introduced base and derived classes –overriding existing behaviour with new behaviour adding new behaviour will be covered lateradding new behaviour will be covered later –we used the virtual method technique in the examples