COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Sample Development: HiLo Game *Chapter 6: Console.

Slides:



Advertisements
Similar presentations
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 6 Repetition Statements.
Advertisements

15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Graphical User Interfaces (Part IV)
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 6 Repetition Statements Animated Version.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 : Event-Driven Programming and GUI Objects.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Four: Defining Your Own Classes *Instantiable.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3: *Sample Development Loan Calculator.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Spring 2005 Chapter 8  Errors and Exceptions Throwable class.
بسم الله الرحمن الرحيم CPCS203: Programming II. Objectives After you have read and studied this chapter, you should be able to Implement repetition control.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 14 GUI and Event-Driven Programming.
Chapter Chapter 6 Repetition Statements. Objectives Understand repetition control (loop ) statements in Java: while statement. do-while statement.
Chapter 7 Improving the User Interface
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 10 Using arrays to create collections.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 2 Image Slides.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Chapter 8 Traffic-Analysis Techniques. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-1.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 14 Animation Slides To run the animations you must.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
Java Programming Chapter 10 Graphical User Interfaces.
Chapter 6 – Repetition Statements : Objectives After you have read and studied this chapter, you should be able to Implement repetition control in a program.
1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 3 Animation Slides To run the animations you must.
1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 08 Animation Slides To run the animations you must.
JLabel, JTextField, JButton and JOptionPane
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T E N Event-Driven Programming.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
CS1101X: Programming Methodology Recitation 3 Control Structures.
1 Chapter 14 Animation Slides Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. To run the animations you must.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Lecture 00 Swing overview and introduction Lynda Thomas
COMP 321 Week 2. Outline Event-Driven Programming Events, Event Sources, Event Listeners Button and Timer Events Mouse Events, Adapters.
Discussion 4. Labs public MyPoint(double xInit, double yInit ) { MyPoint p = new MyPoint(0, 0); } ClassProblem.java recursive java.lang.StackOverflowError.
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
Graphical User Interfaces (Part 2) 1. View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7-2 ( Book Chapter 14) GUI and Event-Driven Programming.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Review_6 AWT, Swing, ActionListener, and Graphics.
Graphical User Interfaces Tonga Institute of Higher Education.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7-3 ( Book Chapter 14) GUI and Event-Driven Programming.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 18 List ADT Animated Version.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
View  view  presents the user with a sensory (visual, audio, haptic) representation of the model state  a user interface element (the user interface.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
MIT AITI 2004 Swing Event Model Lecture 17. The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the.
Chapter 13 Transportation Demand Analysis. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
Introduction to OOP with Java 4th Ed, C. Thomas Wu
Java Programming: From Problem Analysis to Program Design,
Ellen Walker Hiram College
Graphical User Interfaces in Java Event-driven programming
Tonga Institute of Higher Education
Presentation transcript:

COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Sample Development: HiLo Game *Chapter 6: Console version *Chapter 7: GUI version

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Hi-Lo Game *Objective is to guess a secret number between 1 and 100. *After each guess, program will say if guess was high or low. *Maximum number of guesses is 6.

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Problem Statement *Write an application that plays the Hi-Lo game with the user *User should be able to play as many games as he/she wants. do { generate secret number play one game } while (user wants to play);

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Development Steps (Chapter 6) 1.Skeleton Ch6HiLo class 2.Code for playing game 3.Random number generation 4.Finalize the code

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Skeleton Class *Make an instantiable main class *Main method creates a HiLo object *HiLo class has a start method describeRules(); ans = prompt( "Play?"); while (ans == "yes") { generateSecretNumber(); playGame(); ans = prompt( "Play?"); }

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Testing *Put print statements in all methods *Run program with 0, 1 and more than one game

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Develop playGame method *Use a dummy secret number Used by more than one method *Need a counter to keep track of the number of guesses guessCount = 0; do { getNextGuess(); guessCount++; // test for hi or lo } while (guessCount<maxGuesses && guess != secretNumber); // Report win or lose

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Testing Step 2 *Test with out of range numbers ( 100) *Test with numbers between 2 and 99 *Test with 1 *Test with 100

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Generate a random number *Write generateSecrtetNumber method Add a print statement to display the random number *Write a separate test class to check the code that goes into the method

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Finalize *Write describeRules *Remove testing code *Check for omissions *Re-test the entire program

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. GUI HiLo Game (Chapter 7) *Use a graphical User Interface and event driven logic *Classes to write Ch7HiLoFrame Ch7HiLo *Development Plan 1.Create skeleton Ch7HiLoFrame class with menus 2.Design and implement GUI layout 3.Implement game-playing logic 4.finalize

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Ch7HiLoFrame *extends JFrame *implements ActionListener *Menus Game New Quit Help GameRules About

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 1 *Skeleton class *Create the menus *Implement the quit option *Print name of other menu items *Test by selecting all menu items

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. GUI Layout *Use JTextField for entering guess *Use Jlable to report Hi or Lo *Two Jbuttons Guess to enter guess Cancel to clear the JTextField

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Sample GUI Program

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 2 *Add components to frame *Put stubs for remaining menu items *Test by selecting all menu items, clicking buttons and entering something in the JTextField

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 3 *Implement the Ch7HiLo Class Similar to Ch6HiLo except that we need methods that can be called from the Ch7HiLoFrame class *Create a Ch7HiLo object in the Ch7HiLoFrame class *Call the newGame method when New menu item is selected

COMPSCI 125 Spring 2005 ©The McGraw-Hill Companies,Inc. Permission required for reproduction or display. Step 4 *Implement the Help menu items *Do the final testing