April 5, 2002 - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

April 5, 2002

Description:

use the rand function from stdlib.h ... the sequence you get is always the same. use % to get numbers from 1 to 6 ... yahtzee. NOW DUE: April 12 ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 9
Provided by: teres1
Category:
Tags: april | yahtzee

less

Transcript and Presenter's Notes

Title: April 5, 2002


1
April 5, 2002
2
Exam 3
  • April 10
  • files, arrays, strings, classes
  • practice exams are up
  • review on Monday

3
Random numbers
  • use the rand function from stdlib.h
  • int rand() returns an integer from 0 to RAND_MAX
    (a big number)
  • the sequence you get is always the same
  • use to get numbers from 1 to 6
  • dieValue 1 rand() 6

4
randomizing dice
  • include lttime.hgt
  • at the top of your main function
  • srand( time( NULL))
  • See testFns for an example

5
yahtzee
  • NOW DUE April 12
  • you may write a single player game (since my
    Player class doesn't seem to be getting written)
  • input and output format are up to you this time
  • please explain the input required of the user in
    your readme

6
static members
  • functions and variables
  • belong to the class as a whole rather than a
    specific instance
  • use them with className in front of the name
    (object reference will also work)

7
Common Programming Errors
  • Not defining a function as a member of a class
  • Referencing a private attribute of a class
  • Missing header files
  • Missing on class definition

8
Common Programming Errors
  • Mismatch in signature between header and function
    definitions
  • Prefixing a class function call
  • obj.function()
  • don't use class name except for static functions
  • trying to access instance variables from a static
    function
Write a Comment
User Comments (0)
About PowerShow.com