日期:2014-05-20 浏览次数:20768 次
class DayWorker{
private Integer workerMun;
private String[] day ;
public Integer getWorkerMun() {
return workerMun;
}
public void setWorkerMun(Integer workerMun) {
this.workerMun = workerMun;
}
public String[] getDay() {
return day;
}
public void setDay(String[] day) {
this.day = day;
}
}
public class Test {
public static Map< String, DayWorker> addMap(Map< String, DayWorker> map, List<String> workerList , int day){
String [] dayStr ={"workerListMon" ,"workerListTues","workerListWed","workerListThurs","workerListFri"} ;
for (String key : workerList) {
if(!map.containsKey(key)){
DayWorker worker = new DayWorker() ;
worker.setWorkerMun(1);
String [] dayName = new String[5] ;
dayName[0] =dayStr[day-1] ;
worker.setDay(dayName) ;
map.put(key, worker) ;
}else{
DayWorker worker = map.get(key) ;
worker.setWorkerMun(worker.getWorkerMun()+1) ;
String[] dayName = worker.getDay() ;
dayName[day-1] = dayStr[day-1] ;
worker.setDay(dayName) ;
}
}
return map ;
}
public static void main(String[] args) throws Exception {
//初始数据
List<String> workerListMon = new ArrayList<String>();
List<String> workerListTues = new ArrayList<String>();
List<String> workerListWed = new ArrayList<String>();
List<String> workerListThurs = new ArrayList<String>();
List<String> workerListFri = new ArrayList<String>();
for (int i = 1; i < 7; i++) {
String s = "worker"+ i ;
if(i == 1
------解决方案--------------------
i == 2