Java如何实现的程序员老黄历
这篇文章将为大家详细讲解有关Java如何实现的程序员老黄历,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
石嘴山网站建设公司成都创新互联,石嘴山网站设计制作,有大型网站制作公司丰富经验。已为石嘴山成百上千提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的石嘴山做网站的公司定做!
代码如下:
代码段1
package com.test; /** * activities的枚举 * @author Xiao * */ public enum ActivitiesEnum { ACTIVITIES_1("写单元测试", "写单元测试将减少出错", "写单元测试会降低你的开发效率", false), ACTIVITIES_2("洗澡", "你几天没洗澡了?", "会把设计方面的灵感洗掉", true), ACTIVITIES_3("锻炼一下身体", "", "能量没消耗多少,吃得却更多", true), ACTIVITIES_4("抽烟", "抽烟有利于提神,增加思维敏捷", "除非你活够了,死得早点没关系", true), ACTIVITIES_5("白天上线", "今天白天上线是安全的", "可能导致灾难性后果", false), ACTIVITIES_6("重构", "代码质量得到提高", "你很有可能会陷入泥潭", false), ACTIVITIES_7("使用%t", "你看起来更有品位", "别人会觉得你在装逼", false), ACTIVITIES_8("跳槽", "该放手时就放手", "鉴于当前的经济形势,你的下一份工作未必比现在强", false), ACTIVITIES_9("招人", "你面前这位有成为牛人的潜质", "这人会写程序吗?", false), ACTIVITIES_10("面试", "面试官今天心情很好", "面试官不爽,会拿你出气", false), ACTIVITIES_11("提交辞职申请", "公司找到了一个比你更能干的人,你赶快滚蛋", "鉴于当前的经济形势,你的下一份工作未必比现在强", false), ACTIVITIES_12("申请加薪", "老板今天心情很好", "公司正在考虑裁员", false), ACTIVITIES_13("晚上加班", "晚上是程序员精神最好的时候", "", true), ACTIVITIES_14("在妹子面前吹牛", "改善你矮穷挫的形象", "会被识破", true), ACTIVITIES_15("撸管", "避免缓冲区溢出", true), ACTIVITIES_16("浏览成人网站", "重拾对生活的信心", "你会心神不宁", true), ACTIVITIES_17("命名变量%v", "", "", false), ACTIVITIES_18("写超过%l行的方法", "你的代码组织的很好,长一点没关系", "你的代码将混乱不堪,你自己都看不懂", false), ACTIVITIES_19("提交代码", "遇到冲突的几率是最低的", "你遇到的一大堆冲突会让你觉得自己是不是时间穿越了", false), ACTIVITIES_20("代码复审", "发现重要问题的几率大大增加", "你什么问题都发现不了,白白浪费时间", false), ACTIVITIES_21("开会", "写代码之余放松一下打个盹,有益健康",false), ACTIVITIES_22("打DOTA", "你将有如神助", "你会被虐的很惨", true), ACTIVITIES_23("晚上上线", "晚上是程序员精神最好的时候", "你白天已经筋疲力尽了", false), ACTIVITIES_24("修复BUG", "你今天对BUG的嗅觉大大提高", "新产生的BUG将比修复的更多", false), ACTIVITIES_25("设计评审", "设计评审会议将变成头脑风暴", "人人筋疲力尽,评审就这么过了", false), ACTIVITIES_26("需求评审", "", "", false), ACTIVITIES_27("上微博", "今天发生的事不能错过", "今天的微博充满负能量", true), ACTIVITIES_28("上AB站", "还需要理由吗?", "满屏兄贵亮瞎你的眼", true), ACTIVITIES_29("玩FlappyBird", "今天破纪录的几率很高", "除非你想玩到把手机砸了", true); private String name; private String good; private String bad; private Boolean weekend; ActivitiesEnum(String name, String good, String bad, Boolean weekend){ this.setBad(bad); this.setGood(good); this.setName(name); this.setWeekend(weekend); } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getGood() { return good; } public void setGood(String good) { this.good = good; } public String getBad() { return bad; } public void setBad(String bad) { this.bad = bad; } public Boolean getWeekend() { return weekend; } public void setWeekend(Boolean weekend) { this.weekend = weekend; } }
代码段2
package com.test; public enum SpecialsEnum { SPECIALS(2014, "bad", "待在男(女)友身边", "脱团火葬场,入团保平安。"); private Integer date; private String type; private String name; private String description; SpecialsEnum (Integer date, String type, String name, String description){ this.setDate(date); this.setType(type); this.setName(name); this.setDescription(description); } public Integer getDate() { return date; } public void setDate(Integer date) { this.date = date; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }
代码段3
package com.test; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Random; import org.apache.commons.lang.StringUtils; public class ProgrammerCalendar { private Integer iday = 0; private String [] weeks = new String[]{"日", "一","二","三","四","五","六"}; private String [] directions = new String[]{"北方","东北方","东方","东南方","南方","西南方","西方","西北方"}; private String [] tools = new String[]{"Eclipse写程序", "MSOffice写文档", "记事本写程序", "Windows8", "Linux", "MacOS", "IE", "Android设备", "iOS设备"}; private String [] varNames = new String[]{"jieguo", "huodong", "pay", "expire", "zhangdan", "every", "free", "i1", "a", "virtual", "ad", "spider", "mima", "pass", "ui"}; private String [] drinks = new String[]{"水","茶","红茶","绿茶","咖啡","奶茶","可乐","鲜奶","豆奶","果汁","果味汽水","苏打水","运动饮料","酸奶","酒"}; public Integer getIday() { return iday; } public String[] getDirections() { return directions; } /** * 注意:本程序中的“随机”都是伪随机概念,以当前的天为种子。 */ public Integer random(Integer daySeed, Integer indexSeed) { Integer n = daySeed % 11117; for (int i = 0; i < 100 + indexSeed; i++) { n = n * n; n = n % 11117; //11117是个质数 } return n; } public String getTodayString (){ Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); return "今天是" + calendar.get(Calendar.YEAR) + "年" + (calendar.get(Calendar.MONTH) + 1) + "月" + calendar.get(Calendar.DAY_OF_MONTH) + "日 星期" + weeks[calendar.get(Calendar.DAY_OF_WEEK) - 1]; } public String star(Integer num) { String result = ""; int i = 0; while (i < num) { result += "★"; i++; } while(i < 5) { result += "☆"; i++; } return result; } private Boolean isWeekend() { Locale.setDefault(Locale.CHINA); Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.DAY_OF_WEEK) == 1 || calendar.get(Calendar.DAY_OF_WEEK) == 7; } public Listfilter() { List thisEnum = new ArrayList (); // 周末的话,只留下 weekend = true 的事件 if(isWeekend()) { for (ActivitiesEnum e : ActivitiesEnum.values()) { if(e.getWeekend()){ thisEnum.add(e); } } return thisEnum; } return new ArrayList (Arrays.asList(ActivitiesEnum.values())); } public void pickTodaysLuck() { List _activities = filter(); Integer numGood = random(iday, 98) % 3 + 2; Integer numBad = random(iday, 87) % 3 + 2; List
运行结果:
今天是:今天是2021年4月15日 星期四
座位朝向:面向西方写程序,BUG 最少。
今日宜饮:可乐,果汁
女神亲近指数:★★☆☆☆
宜:
锻炼一下身体
晚上加班:晚上是程序员精神最好的时候
浏览成人网站:重拾对生活的信心
不宜:
打DOTA:你会被虐的很惨
上AB站:满屏兄贵亮瞎你的眼
关于“Java如何实现的程序员老黄历”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。
名称栏目:Java如何实现的程序员老黄历
文章链接:http://azwzsj.com/article/gdjhhh.html