TCU CoSc 10403 Programming with Java - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

TCU CoSc 10403 Programming with Java

Description:

TCU CoSc 10403. Programming with Java. Lecture 5. Program Design & Widgets II. Agenda ... More examples. Exercise 8 in chapter 3. Others ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 8
Provided by: drlisab
Category:

less

Transcript and Presenter's Notes

Title: TCU CoSc 10403 Programming with Java


1
TCU CoSc 10403 Programming with Java
  • Lecture 5
  • Program Design Widgets II

2
Agenda
  • Last time
  • Chapter 3 widgets
  • Today
  • Program design
  • Wormhole design (lablet 2)
  • More on color
  • Writing your own methods
  • More widgets
  • Read chapter 3

3
A color review (optional)
  • Reference pages 46 53 (wormhole)
  • Color myColor new Color(255, 0, 128)
  • g.setColor(myColor)
  • g.fillRect(10,20,100,200)
  • // If dont need to change this color
  • g.setColor(new Color(255, 0, 128)
  • g.fillRect(10,20,100,200)

4
Scope of variables
  • Wormhole, design pass 2 (page 54)
  • Instance variables
  • Scope is global to the class
  • Defined outside any method (at top)
  • Local variables
  • Scope is local to the method
  • Defined inside a method
  • Guideline use smallest scope needed to ease
    debugging, understanding

5
Program Design
  • Refer to Wormhole, design pass 3 (lablet 2)
  • Writing your own methods (drawHole)
  • Why?
  • Less code (repeated code) see page 58
  • Easier to
  • Read
  • understand
  • modify
  • reuse

6
Program Design
  • Decide
  • What the method needs to do and how to do it
    (algorithm)
  • Local variables and arguments
  • Return type
  • Descriptive method name
  • Use a VERB PHRASE denotes action
  • drawHole, calcGPA, confirmPurchase

7
Widgets
  • Lablet 3 Gigobite
  • Code review
  • View difference when run in appletviewer and Web
    browser
  • More examples
  • Exercise 8 in chapter 3
  • Others
Write a Comment
User Comments (0)
About PowerShow.com