新建分支
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CacheMap {
|
||||
Map<String,String> map = new HashMap(){{
|
||||
put("sign","1");
|
||||
}};
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class WiningUtil {
|
||||
private List<String> participants;
|
||||
private Random random;
|
||||
|
||||
public WiningUtil(List<String> participants) {
|
||||
this.participants = participants;
|
||||
this.random = new Random();
|
||||
}
|
||||
|
||||
public String drawWinner() {
|
||||
if (participants.isEmpty()) {
|
||||
return "No participants to draw from";
|
||||
}
|
||||
|
||||
int index = random.nextInt(participants.size());
|
||||
return participants.get(index);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 参与抽奖的人员名单
|
||||
List<String> participants = new ArrayList<>();
|
||||
participants.add("Alice");
|
||||
participants.add("Bob");
|
||||
participants.add("Charlie");
|
||||
participants.add("David");
|
||||
participants.add("Eve");
|
||||
|
||||
// 创建抽奖对象
|
||||
WiningUtil winingUtil = new WiningUtil(participants);
|
||||
|
||||
// 进行抽奖
|
||||
String winner = winingUtil.drawWinner();
|
||||
System.out.println("Winner: " + winner);
|
||||
}
|
||||
public static boolean winingresult(){
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user