Chapter 6: Controlling Program Flow with Loops 137 (Web server address)

Chapter 6: Controlling Program Flow with Loops 137 Listing 6-5: I Accuse . . . import static java.lang.System.out; class Clue { enum Suspect {mustard, plum, green, peacock, scarlet, white}; enum Room {ballroom, kitchen, diningRoom, lounge, hall, study, library, billiardRoom, conservatory}; enum Weapon {knife, candlestick, revolver, rope, leadPipe, wrench}; public static void main(String args[]) { for (Suspect mySuspect : Suspect.values()) { for (Room myRoom : Room.values()) { for (Weapon myWeapon : Weapon.values()) { out.print(mySuspect); out.print( in the ); out.print(myRoom); out.print( with a ); out.println(myWeapon); } } } Suspect killer = Suspect.peacock; Room sceneOfTheCrime = Room.study; Weapon murderWeapon = Weapon.leadPipe; out.println(); out.print( I accuse ); out.print(killer); out.print( in the ); out.print(sceneOfTheCrime); out.print( with a ); out.print(murderWeapon); out.println( . ); } } The output of the code in Listing 6-5 has 324 lines, so I can t show it all to you. But the first several lines appear in Figure 6-7. First, you see Colonel Mustard s ballroom antics. Then you get Mustard s kitchen tricks. Later in the run, when all Mustard s frolics are finished, you see the same possibilities for Professor Plum.
We are the the largest streaming host company, and we provide professional audio & video web hosting streaming using Real Networks, QuickTime, Flash and Windows Media.We strongly recommend you to visit and check web hosting streaming services.

Leave a Reply