CHAPTER 13B Object Oriented Programming (Tutorial)

Slides:



Advertisements
Similar presentations
Chapter 3 – Web Design Tables & Page Layout
Advertisements

1 After completing this lesson, you will be able to: Insert a table. Navigate and select cells within a table. Merge table cells. Insert and delete columns.
MS® PowerPoint.
Objectives © Paradigm Publishing, Inc. 1 Objectives.
C++ Classes & Data Abstraction
Using Macros and Visual Basic for Applications (VBA) with Excel
CHAPTER 10 FUN AND GAMES Group 1: Xiangling Liu.
Copyright 2003 Peter McDevitt 1 Microsoft Excel 2002 Lecture 3 – A Professional Looking Worksheet.
CS102--Object Oriented Programming Discussion 2: (programming strategy in java) – Two types of tasks – The use of arrays Copyright © 2008 Xiaoyan Li.
CHAPTER 13 Object Oriented Programming. Objectives  Design class definitions  Implement data hiding and encapsulation  Use accessor and mutator methods.
Visual C++ Programming: Concepts and Projects Chapter 13A: Object-Oriented Programming (Concepts)
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 3 1 Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional- Looking.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Create slices and hotspots Create links in Web pages Create rollovers from slices Create basic animation Add tweening symbol instances to create animation.
1 Computing for Todays Lecture 20 Yumei Huo Fall 2006.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L03 (Chapter 15) Creating.
UML Class Diagram: class Rectangle
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Visual C++ Programming: Concepts and Projects
XP 1 Microsoft Office Excel Developing a Professional-Looking Worksheet.
AE4131 ABAQUS Lecture Part IV
XP New Perspectives on Microsoft Office PowerPoint 2003 Tutorial 2 1 Microsoft Office PowerPoint 2003 Tutorial 2 – Applying and Modifying Text and Graphic.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Tutorial 5 Making a Document Interactive. XP Objectives Explore the different button states Add a button from the Button library Create a button Learn.
Tutorial 5 Making a Document Interactive. XP Objectives Explore the different button states Add a button from the Buttons library Edit a button instance.
P. Nikravesh, AME, U of A Using the SlidesIntroduction Using the slides This presentation provides the necessary information on how to use these Power-Point.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional-Looking Worksheet.
Microsoft Word 2000 Presentation 5. Major Word Topics Columns Tables Lists.
XP New Perspectives on Microsoft Excel 2002 Tutorial 3 1 Microsoft Excel 2002 Tutorial 3 – Developing a Professional Looking Worksheet.
XP New Perspectives on Microsoft Word 2002 Tutorial 31 Microsoft Word 2002 Tutorial 3 – Creating a Multiple-Page Report.
Notes to Teachers: 1.These Excel modules are intended for higher level ESL learners and native speaking students. 2.Place the document: “cell phone workbook.xlsx”
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
XP New Perspectives on Microsoft PowerPoint 2002 Tutorial 2 1 Microsoft PowerPoint 2002 Tutorial 2 – Applying and Modifying Text and Graphic Objects.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Game Maker Terminology
Sequence Diagrams And Collaboration Diagrams HungNM.
Visual C++ Programming: Concepts and Projects Chapter 11B: Pointers (Tutorial)
® Microsoft Access 2010 Tutorial 10 Automating Tasks with Macros.
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Visual C++ Programming: Concepts and Projects Chapter 12B: Linked List (Tutorial)
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 6B Methods (Tutorial)
Excel Screen Slide 1 Column Row Cell Formula bar Column heading Row heading Worksheet tab.
line.net/ okpop.com/bar elythereflashin dex.html.
Presented By: Weidong WU, Ph.D. Date: Part I Creating a drawing format for the paper size A (11 x 8.5) 1. Start Pro/E wildfire. 2. File  set.
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
1NetBeans Tutorial Using the “Properties” menu, name the List “List1” and the button “Button1”. NetBeans Tutorial6.
Microsoft Excel Microsoft Excel 2013 is a spreadsheet application in the Microsoft Office Suite. A spreadsheet is an accounting program for the.
Chomp. How is the game played Human player goes first choose a square, all to the right and down are “eaten” computer takes a turn whoever is forced to.
Visual C++ Programming: Concepts and Projects Chapter 10B: Recursion (Tutorial)
PaintPictureBoxDemo Refers to the PaintPictureBoxDemo Visual Basic Program Included With The Lecture.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Visual C++ Programming: Concepts and Projects
Microsoft Excel This class is “HANDS-ON” you will need to open up an excel spreadsheet and do examples as you go along. Students will be able to follow.
UML Class Diagram: class Rectangle
Chapter 13: Advanced GUIs and Graphics
Creating and Using Classes
Signature: Microsoft Word 2003
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
ITEC 1001 Test 5 Review.
Lesson 1 - Automating Tasks
Steps to Build Frame Window Recipe Application
Advanced GUIs and Graphics
Day 3: Working with Tables
Presentation transcript:

CHAPTER 13B Object Oriented Programming (Tutorial)

Course Evaluations  Today you will evaluate the lecture portion of the course  Call number:  Semester: 5  On Monday we will evaluate the TAs

Tutorial: Maze Program  Problem Analysis  Create a program in which a mouse navigates a maze looking for the hidden cheese  The maze consists of a two-dimensional array of cells  The Mouse is an object created from a Mouse class definition  Each cell in the maze is an object created from a Cell class defintion

Problem Analysis

Development (continued)

The Mouse Class Definition  Class variables  Various icons of mouse facing different directions  private data members  row and column locations of the mouse in the maze ( row and col )  Icon  private methods  Default constructor – Mouse()

The Mouse Class Definition (continued)  public methods  Initializing constructor – Mouse(int, int)  Accessor methods getRow() getCol() getIcon()  Mutator methods setRow() setCol()

The Mouse Class Definition (continued)  public methods  Utility methods goRight() goLeft() goUp() goDown()

The Mouse Class Definition (continued)

The Cell Class Definition  private data members  row : int – row location of Cell in maze  col : int – column location of Cell in maze  access : bool – indicates whether Mouse can enter this Cell  hasCheese : bool – indicates whether cheese is in this Cell  private methods  Default constructor – Cell()

The Cell Class Definition (continued)  public methods  Initializing constructor – Cell(int, int)  Accessor methods getRow() getCol() getAccess() getCheese()  Mutator methods setAccess() setCheese()

The Cell Class Definition (continued)

Design  A maze consists of rows and columns  Rows run horizontally  Columns run vertically  Each cell has a row and column location

Design (continued)

 The interface contains two buttons (used to start and stop the animation)  A Timer control is used to perform Mouse movement  The Mouse moves from one Cell to another  Previous cells are colored brown  When the mouse reaches the cell with the cheese a MessageBox pops up

Design (continued)

 The size of Cells and the number of rows and columns of Cells in the maze are constants

Design (continued)

 The maze is a two-dimensional array of Cells  Use the Array template as a foundation for this

Design (continued)  Instance variables include the mouse, maze and a variable to indicate which direction the mouse is moving

Design (continued)  Creating the maze requires the instantiation of 320 Cell objects (20 in each row)

Design (continued)  The Form1_Load() event will construct the interface, complete with maze, mouse and cheese

Design (continued)  Drawing the maze (nested loops for rows and columns)

Design (continued)  Drawing and positioning the Mouse

Design (continued)  Keep the mouse in the maze by checking for edges

Development  Interface construction (only two buttons)  Timer control used to control movement  Form1_Load() will draw the maze initially  The maze and mouse are redrawn in each Timer_Tick() event

Development (continued)

 The Mouse and Cell classes must both be included at the top of the client (Form1.h)

Development (continued)  Instance variables, constants and object handles

Development (continued)  Form1_Load() constructs the maze

Development (continued)  The start button creates the mouse and cheese

Development (continued)  The mouse and cheese icons are displayed in Rectangles

Development (continued)  The maze cells are drawn in drawMaze( )

Development (continued)  At each interval of the Timer, its Tick() event  Redraws the maze  Draws the mouse at its new location  The animation can be halted with btnStop_Click()

Development (continued)  The Timer1_Tick() event  Creates a Rectangle based on the cell in which the mouse currently resides ( oldRect )

Development (continued)  If mouse is not at edge then move in current direction

Development (continued)  If mouse moves into cell with cheese congratulations!  If mouse was at an edge then choose new direction

Development (continued)  Check for edges by checking row and column

Testing  When btnStart is clicked  Maze appears (16 rows x 20 columns of cells)  Mouse and cheese appear  Mouse moves across the maze from left to right  When mouse reaches the edge it turns and follows the edges around  Reposition the cheese so that the mouse finds it in its path

On Your Own  Stronger mutators  Do not allow negative values  Private instance methods  verifyRow() and verifyCol() for Mouse class  New UML class diagram  Add verifyRow() and verifyCol() to Mouse UML diagram