APCS Unit 6 - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

APCS Unit 6

Description:

Chapter 4 & 5 Quiz. Turn off your monitor and clear your desk. After ... Craps Example. Unit6_Lecture ... java, RollDie.java, Craps.java, CrapsTest.java ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 14
Provided by: SDU29
Category:
Tags: apcs | craps | unit

less

Transcript and Presenter's Notes

Title: APCS Unit 6


1
APCS Unit 6
  • Methods A Deeper Look

2
Agenda 9/22
  • Turn in ch.5 Homework
  • Exercise 5.23, 5.27, 5.29
  • Chapter 4 5 Quiz
  • Turn off your monitor and clear your desk.
  • After you complete the quiz
  • Read ch.6 Section 6.1-6.5 (pg.231-240)
  • Look up one class (your choice) in the Java API
    check the course web site for the link Diagram
    the class in UML (include constructors, methods,
    etc).

3
Agenda 9/23
  • Review Homework
  • Exercise 5.23, 5.27, 5.29
  • Chapter 6 - Section 6.1-6.5 (pg.231-240)
  • Unit6_Lecture.ppt (Slides 1-25)
  • Section 6.6-6.9
  • Unit6_Lecture.ppt (Slides 27-46)
  • Project 1 Due9/26
  • MidTermCh1-6 Tuesday (9/30)

4
Agenda 9/23 Cont.
  • Homework
  • 6.12
  • Read Chapter 6 (Sec 6.6-6.9)
  • MidTermCh1-6 Tuesday (9/30)

5
Agenda 9/24
  • Warm-Up ON A PIECE OF PAPER
  • Write a class MinimumFinder containing a method
    which finds the mininum of 4 doubles input by the
    user. The method should be called using another
    class called MinimumFinderTest.
  • Review Homework
  • Maximum Finder and 6.12
  • Recap Section 6.6-6.9
  • Unit6_Lecture.ppt (Slides 27-46)

6
Agenda 9/24 Cont.
  • Homework
  • 6.13
  • 6.23
  • MidTermCh1-6 Tuesday (9/30)

7
Agenda 9/25
  • Warm-up
  • Debug Warmup6.9
  • Review 6.1 6.9
  • Static Methods ? Class Methods
  • Apply to the class as a whole
  • Does your method operate on the state of an
    object?
  • If the method DOES NOT modify the instance
    variables of an object it should be declared
    static
  • Usable to anyone with access to the class
  • Class.Method(Arguments)
  • Non Static Methods ? Instance Methods
  • Must be invoked on a particular instance of a
    class

8
Agenda 9/25
  • Static fields ? Class variables
  • One copy of the variable is shared among all
    objects in the class
  • Often declared as final ? constant variables
  • Example In The Math Class
  • public static final double PI (all caps to show
    Final variable)
  • Public static final double E
  • Constant variables used throughout the Math class
  • Math.PI Math.E
  • Main Method
  • Declared static so that it can be invoked without
    creating an instance of the class
  • Often just used to test and run applications

9
Agenda 9/25
  • Argument Promotion and Casting
  • The table shows that the promotions start from
    boolean and go up to double
  • There is no promotion for a double

10
Agenda 9/25
  • Java API Packages
  • http//java.sun.com/javase/6/docs/api/
  • What is available for use
  • Intro to Enumerators
  • Craps Example
  • Unit6_Lecture ?Slides (48-50)
  • Scope
  • Create a project in Eclipse and import the
    Fig06_11_12 texbook examples into the project
  • Running a program in Debug mode to see the scope
  • Unit6_Lecture ?Slides (51-58)

11
Agenda 9/25 Cont.
  • Homework
  • Generate a test driver which uses the Random
    class to generate a distribution (histogram) of
    random numbers between 1 and 10. The program
    should run 10,000 events and output a bar graph
    comprised of a number of asterisks corresponding
    to the distribution bins. Note, make the number
    of asterisks relative (dont output 1,000
    asterisks).
  • Extra Credit (up to 5 points added to midterm
    grade)
  • Create one turn of the game Yatzee
  • Up to 5 die are rolled 3 times
  • User decides which die to keep for each roll
  • Program generates random numbers for each die
    roll, holding the die identified by the user
  • Reference RandomIntegers.java, RollDie.java,
    Craps.java, CrapsTest.java
  • MidTermCh1-6 Tuesday (9/30)

12
Agenda 9/26
  • Warm-up What is the output if the begin method
    is executed
  • You need to check ? Slide 60 - Unit6_Lecture.ppt
  • Overloaded Methods
  • Unit6_Lecture.ppt (Slide 61-65)
  • Projects are due today
  • Do not Panic
  • Print your class files from Eclipse
  • Run your program and copy the output from Eclipse
    to a text editor (notepad or word). If it needs
    to be bigger or bold so that the design is more
    visible please make those adjustments.
  • Print the Output design from the text editor
  • Make sure your name is on the print out and turn
    the papers in with the design stapled on top.

13
Agenda 9/26 Cont.
  • Homework
  • Modify MethodOverload to create an overloaded
    method called square which inputs 2 integers and
    checks that the inputs are the same, then returns
    the square. If the two integers are not the same
    the method prints a message and returns 0.
  • 6.30
  • MidTermCh1-6 Tuesday (9/30)
Write a Comment
User Comments (0)
About PowerShow.com