// Stuart Reges handout #4 // 10/1/04 // // This program demonstrates the use of static methods to produce output. It // has methods that produce various paragraphs for a letter and combines these // to produce a series of three letters. public class Letters { public static void main(String[] args) { mom(); andy(); wendy(); } // a letter to Mom public static void mom() { System.out.println("Dear Mom:"); System.out.println(); work(); live(); amc(); bye(); } // a letter to Andy public static void andy() { System.out.println("Dear Andy:"); System.out.println(); work(); live(); scifi(); bye(); } // a letter to Wendy public static void wendy() { System.out.println("Dear Wendy:"); System.out.println(); work(); live(); scifi(); amc(); bye(); } // produces a paragraph describing work public static void work() { System.out.println("Work is going great. I gave my first lecture"); System.out.println("on Wednesday. I was a bit nervous, but it"); System.out.println("turned out okay. I can always count on the"); System.out.println("Star Trek stuff to get a laugh."); System.out.println(); } // produces a paragraph describing where I live public static void live() { System.out.println("I bought a loft in downtown Seattle in a part"); System.out.println("of town they call Pioneer Square. I take the"); System.out.println("bus to work and that's pretty convenient."); System.out.println("It gets a bit noisy on Friday and Saturday"); System.out.println("nights, but I've bought a laser pointer that"); System.out.println("I shine down from my window to confuse the"); System.out.println("drunk people."); System.out.println(); } // produces a paragraph describing what's happening on All My Children public static void amc() { System.out.println("Can you believe what's happening on All My"); System.out.println("Children? I can't believe that Babe still"); System.out.println("hasn't told Bianca that she stole her baby."); System.out.println("And it's so weird watching Tad being a father"); System.out.println("to a grown-up son. I remember when he was in"); System.out.println("high school and sleeping with both Liza and her"); System.out.println("mother at the same time."); System.out.println(); } // produces a paragraph about science fiction TV shows public static void scifi() { System.out.println("Did you hear that Brent Spiner is going to be"); System.out.println("on Enterprise next year? It sounds stupid. I"); System.out.println("think they ruined Stargate by having O'Neil no"); System.out.println("longer going out on missions. The new Stargate"); System.out.println("Atlantis is okay, but it's like vampires in"); System.out.println("outer space. Ann Rice meets Larry Niven."); System.out.println(); } // produces a closing for the letter public static void bye() { System.out.println("See ya later,"); System.out.println(); System.out.println(); System.out.println("Stuart"); System.out.println("\f"); // form feed to go to new page } }
Stuart Reges
Last modified: Fri Oct 1 14:52:18 PDT 2004