|
home—info—lects—labs—exams—hws
tutor/PIs—Object120 + its docs—java.lang docs—java.util docs
/** Return whether or not the person must register with Selective Service. * @param age The person's age, in entire years. (E.g. 18mos would be 1 entire year). * @param ___ _______________________________________________ * @return whether or not the person must register with Selective Service. */ boolean mustRegisterForDraft_v2( int age, ____ ______ ) { return _ (age >= 18) __ _______ _; } static void testDraft() { System.out.println("" } |
/** Return a greeting, selected randomly from a list of several greetings. * @return A greeting (randomly selected, not necessarily uniformly). */ static String greet() { int choice = randomInt(100); // Object120.randomInt(n) returns a number in [0,n) = {0,1,2,...,n-1}. String msg; if (choice < 30) { msg = "Hello."; } else if (choice < 33) { msg = "Aloha."; } else if (choice < 50) { msg = "Buenos dias, amigo/amiga."; } else if (choice < 99) { msg = "Yo."; } else if (choice < 100) { // Not an advisable greeting. Use sparingly. msg = "I am a javabot: System dot out dot println open \"hello\" close."; } else { System.err.println( "Uh-oh, I didn't expect to reach here!" ); msg = "A dummy initialiazation for `msg`, to appease the compiler."; } return msg; } |
home—info—lects—labs—exams—hws
tutor/PIs—Object120 + its docs—java.lang docs—java.util docs
©2010, Ian Barland, Radford University Last modified 2010.Sep.29 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |