码迷,mamicode.com
首页 > 其他好文 > 详细

练习:专家术语学习机

时间:2014-12-19 20:29:27      阅读:350      评论:0      收藏:0      [点我收藏+]

标签:

 1 package com.hfjava5;
 2 
 3 public class PhraseOMatic {
 4     public static void main(String[] args) {
 5         String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B",
 6                 "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma",
 7                 "critical-path", "dynamic"};
 8         String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", 
 9                 "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", 
10                 "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};
11         String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency",
12                 "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};
13         
14         // 计算每一组有多少个名词术语
15         int oneLength = wordListOne.length; // 12
16         int twoLength = wordListTwo.length; // 18
17         int threeLength = wordListThree.length; // 12
18         
19         /*    Java本身有一组立即可用的数学方法
20          *  random()会返回介于0与1之间的值,所以需要将此值乘以数组的元素数量(数组的大小),然后取*整数值*(第4章)
21          *  如果需要对任何浮点数取整数值也是用这样的方法转换数据类型
22          */
23         // 产生随机数字
24         int rand1 = (int) (Math.random() * oneLength); // 0-12
25         int rand2 = (int) (Math.random() * twoLength); // 0-18 
26         int rand3 = (int) (Math.random() * threeLength); // 0-12
27         
28         // 组合出专家术语
29         String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
30         
31         System.out.println("What we need is a " + phrase);
32     }
33 }

 

练习:专家术语学习机

标签:

原文地址:http://www.cnblogs.com/fatoland/p/4174565.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!