프로그래머 노 란 달력 자바 소스 코드 구현
11790 단어 자바
원래 JS 버 전 주소:http://sandbox.runjs.cn/show/ydp3it7b/
원작 존중... 하하 하.
코드 는 다음 과 같 습 니 다:
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;
}
}
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;
}
}
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 List filter() {
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
: 2016 9 25
: ,BUG 。
: ,
:★★☆☆☆
:
:
:
:
DOTA:
AB :
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.