CSE 142 Lecture Notes - Lecture 14: Dont
CSE 142 verified notes
14/30View all
Document Summary
For ( int i = 0; i < 5; i++) { 1 // this program demonstrates some basic usage of booleans types. Notice the use of good "boolean zen" and the. 3 // "innocent until proven guilty" pattern in the gotheads. 8 public static void main(string[] args) { 16 for ( int i = 0; i < 5; i++) { 26 // write a method countheads that takes an integer and a random. 27 // object as parameters and simulates flipping a coin the given. The method hsould return the number of flips. 31 // int numflips - the maximum number of times to flip. 32 // random rand - the random object to use for randomization. 33 public static int countheads( int numflips, random rand) { // bad boolean zen - don"t do this! 35 for ( int i = 0; i < numflips; i++) { 44 // write a method gotheads that takes an integer and a random.