diff --git a/chap01/PhraseOMatic.java b/chap01/PhraseOMatic.java index 9163823..7deb1f2 100755 --- a/chap01/PhraseOMatic.java +++ b/chap01/PhraseOMatic.java @@ -1,23 +1,31 @@ package chap01; public class PhraseOMatic { - public static void main(String[] args) { - String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B", - "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma", - "critical-path", "dynamic"}; - String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", - "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", - "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"}; - String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency", - "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"}; - int oneLength = wordListOne.length; - int twoLength = wordListTwo.length; - int threeLength = wordListThree.length; - int rand1 = (int) (Math.random() * oneLength); - int rand2 = (int) (Math.random() * twoLength); - int rand3 = (int) (Math.random() * threeLength); - - String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3]; - System.out.println("What we need is a " + phrase); + public static void main (String[] args) { + String[][] wordMatrix = { + { + "24/7", "multi-Tier", "30,000 foot", "B-to-B", + "win-win", "frontend", "web-based", "pervasive", "smart", + "six-sigma", "critical-path", "dynamic" + }, + { + "empowered", "sticky", "value-added", "oriented", + "centric", "distributed", "clustered", "branded", "outside-the-box", + "positioned", "networked", "focused", "leveraged", "aligned", "targeted", + "shared", "accelerated" + }, + { + "process", "tipping-point", "solution", "architecture", + "core competency", "strategy", "mindshare", "portal", "space", "vision", + "paradigm", "mission" + }}; + + String phrase = ""; + + for (int n = 0; n < wordMatrix.length; ++n) + phrase = String.format("%s %s", + phrase, wordMatrix[n][(int) (Math.random() * wordMatrix[n].length)]); + + System.out.format("What we need is a %s.\n", phrase); } }