Compare commits

...

2 Commits

@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "auto"
}

@ -0,0 +1,121 @@
package com.badminton.entity;
import java.util.Date;
/**
*
* FR-02
*/
public class Match {
private String matchId;
private String matchName;
private String matchType; // 单打/双打/混合双打
private Date startTime;
private Date endTime;
private String location;
private String registrationCondition;
private int maxParticipants;
private String status; // 未开始/报名中/进行中/已结束
public Match() {}
public Match(String matchId, String matchName, String matchType, Date startTime,
Date endTime, String location, String registrationCondition,
int maxParticipants, String status) {
this.matchId = matchId;
this.matchName = matchName;
this.matchType = matchType;
this.startTime = startTime;
this.endTime = endTime;
this.location = location;
this.registrationCondition = registrationCondition;
this.maxParticipants = maxParticipants;
this.status = status;
}
// Getter和Setter方法自动生成右键→Source Action→Generate Getters and Setters
public String getMatchId() {
return matchId;
}
public void setMatchId(String matchId) {
this.matchId = matchId;
}
public String getMatchName() {
return matchName;
}
public void setMatchName(String matchName) {
this.matchName = matchName;
}
public String getMatchType() {
return matchType;
}
public void setMatchType(String matchType) {
this.matchType = matchType;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getRegistrationCondition() {
return registrationCondition;
}
public void setRegistrationCondition(String registrationCondition) {
this.registrationCondition = registrationCondition;
}
public int getMaxParticipants() {
return maxParticipants;
}
public void setMaxParticipants(int maxParticipants) {
this.maxParticipants = maxParticipants;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "Match{"
+ "matchId='" + matchId + '\''
+ ", matchName='" + matchName + '\''
+ ", matchType='" + matchType + '\''
+ ", startTime=" + startTime
+ ", endTime=" + endTime
+ ", location='" + location + '\''
+ ", status='" + status + '\''
+ '}';
}
}

@ -0,0 +1,97 @@
package com.badminton.entity;
import java.util.Date;
/**
*
* FR-07
*/
public class Notification {
private String notificationId;
private String senderId;
private String receiverId;
private String title;
private String content;
private Date sendTime;
private String status; // 未读/已读
public Notification() {}
public Notification(String notificationId, String senderId, String receiverId,
String title, String content, Date sendTime, String status) {
this.notificationId = notificationId;
this.senderId = senderId;
this.receiverId = receiverId;
this.title = title;
this.content = content;
this.sendTime = sendTime;
this.status = status;
}
// Getter和Setter方法
public String getNotificationId() {
return notificationId;
}
public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}
public String getSenderId() {
return senderId;
}
public void setSenderId(String senderId) {
this.senderId = senderId;
}
public String getReceiverId() {
return receiverId;
}
public void setReceiverId(String receiverId) {
this.receiverId = receiverId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getSendTime() {
return sendTime;
}
public void setSendTime(Date sendTime) {
this.sendTime = sendTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "Notification{"
+ "notificationId='" + notificationId + '\''
+ ", title='" + title + '\''
+ ", sendTime=" + sendTime
+ ", status='" + status + '\''
+ '}';
}
}

@ -0,0 +1,78 @@
package com.badminton.entity;
import java.util.Date;
/**
*
* FR-03
*/
public class Registration {
private String registrationId;
private String userId;
private String matchId;
private Date registrationTime;
private String status; // 待审核/已通过/已拒绝
public Registration() {}
public Registration(String registrationId, String userId, String matchId,
Date registrationTime, String status) {
this.registrationId = registrationId;
this.userId = userId;
this.matchId = matchId;
this.registrationTime = registrationTime;
this.status = status;
}
// Getter和Setter方法
public String getRegistrationId() {
return registrationId;
}
public void setRegistrationId(String registrationId) {
this.registrationId = registrationId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getMatchId() {
return matchId;
}
public void setMatchId(String matchId) {
this.matchId = matchId;
}
public Date getRegistrationTime() {
return registrationTime;
}
public void setRegistrationTime(Date registrationTime) {
this.registrationTime = registrationTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "Registration{"
+ "registrationId='" + registrationId + '\''
+ ", userId='" + userId + '\''
+ ", matchId='" + matchId + '\''
+ ", registrationTime=" + registrationTime
+ ", status='" + status + '\''
+ '}';
}
}

@ -0,0 +1,108 @@
package com.badminton.entity;
import java.util.Date;
/**
*
* FR-04
*/
public class Schedule {
private String scheduleId;
private String matchId;
private String round; // 轮次:小组赛/1/8决赛/1/4决赛/半决赛/决赛
private String player1Id;
private String player2Id;
private Date matchTime;
private String court; // 场地号
private String refereeId;
public Schedule() {}
public Schedule(String scheduleId, String matchId, String round, String player1Id,
String player2Id, Date matchTime, String court, String refereeId) {
this.scheduleId = scheduleId;
this.matchId = matchId;
this.round = round;
this.player1Id = player1Id;
this.player2Id = player2Id;
this.matchTime = matchTime;
this.court = court;
this.refereeId = refereeId;
}
// Getter和Setter方法
public String getScheduleId() {
return scheduleId;
}
public void setScheduleId(String scheduleId) {
this.scheduleId = scheduleId;
}
public String getMatchId() {
return matchId;
}
public void setMatchId(String matchId) {
this.matchId = matchId;
}
public String getRound() {
return round;
}
public void setRound(String round) {
this.round = round;
}
public String getPlayer1Id() {
return player1Id;
}
public void setPlayer1Id(String player1Id) {
this.player1Id = player1Id;
}
public String getPlayer2Id() {
return player2Id;
}
public void setPlayer2Id(String player2Id) {
this.player2Id = player2Id;
}
public Date getMatchTime() {
return matchTime;
}
public void setMatchTime(Date matchTime) {
this.matchTime = matchTime;
}
public String getCourt() {
return court;
}
public void setCourt(String court) {
this.court = court;
}
public String getRefereeId() {
return refereeId;
}
public void setRefereeId(String refereeId) {
this.refereeId = refereeId;
}
@Override
public String toString() {
return "Schedule{"
+ "scheduleId='" + scheduleId + '\''
+ ", matchId='" + matchId + '\''
+ ", round='" + round + '\''
+ ", matchTime=" + matchTime
+ ", court='" + court + '\''
+ '}';
}
}

@ -0,0 +1,87 @@
package com.badminton.entity;
/**
*
* FR-05
*/
public class Score {
private String scoreId;
private String scheduleId;
private int player1Score;
private int player2Score;
private String winnerId;
private String status; // 未开始/进行中/已结束
public Score() {}
public Score(String scoreId, String scheduleId, int player1Score,
int player2Score, String winnerId, String status) {
this.scoreId = scoreId;
this.scheduleId = scheduleId;
this.player1Score = player1Score;
this.player2Score = player2Score;
this.winnerId = winnerId;
this.status = status;
}
// Getter和Setter方法
public String getScoreId() {
return scoreId;
}
public void setScoreId(String scoreId) {
this.scoreId = scoreId;
}
public String getScheduleId() {
return scheduleId;
}
public void setScheduleId(String scheduleId) {
this.scheduleId = scheduleId;
}
public int getPlayer1Score() {
return player1Score;
}
public void setPlayer1Score(int player1Score) {
this.player1Score = player1Score;
}
public int getPlayer2Score() {
return player2Score;
}
public void setPlayer2Score(int player2Score) {
this.player2Score = player2Score;
}
public String getWinnerId() {
return winnerId;
}
public void setWinnerId(String winnerId) {
this.winnerId = winnerId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "Score{"
+ "scoreId='" + scoreId + '\''
+ ", scheduleId='" + scheduleId + '\''
+ ", player1Score=" + player1Score
+ ", player2Score=" + player2Score
+ ", winnerId='" + winnerId + '\''
+ ", status='" + status + '\''
+ '}';
}
}

@ -0,0 +1,86 @@
package com.badminton.entity;
/**
*
*
* FR-01
*/
public class User {
private String userId;
private String username;
private String password;
private String realName;
private String phone;
private String role; // player/admin/referee
public User() {}
public User(String userId, String username, String password,
String realName, String phone, String role) {
this.userId = userId;
this.username = username;
this.password = password;
this.realName = realName;
this.phone = phone;
this.role = role;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
@Override
public String toString() {
return "User{"
+ "userId='" + userId + '\''
+ ", username='" + username + '\''
+ ", realName='" + realName + '\''
+ ", phone='" + phone + '\''
+ ", role='" + role + '\''
+ '}';
}
}

@ -0,0 +1,48 @@
// 实验六:用户登录功能实现
package com.badminton.service;
import com.badminton.entity.User;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* FR-01
*/
public class UserService {
private Map<String, User> userDatabase = new HashMap<>();
public UserService() {
// 初始化测试用户
userDatabase.put("admin", new User("U001", "admin", "123456", "系统管理员", "13800138000", "admin"));
userDatabase.put("referee1", new User("U002", "referee1", "123456", "张裁判", "13800138001", "referee"));
userDatabase.put("player1", new User("U003", "player1", "123456", "李选手", "13800138002", "player"));
}
public User login(String username, String password) {
if (!userDatabase.containsKey(username)) {
System.out.println("登录失败:用户名不存在");
return null;
}
User user = userDatabase.get(username);
if (!user.getPassword().equals(password)) {
System.out.println("登录失败:密码错误");
return null;
}
System.out.println("登录成功!欢迎您," + user.getRealName() + "(" + user.getRole() + ")");
return user;
}
public static void main(String[] args) {
UserService userService = new UserService();
// 测试用例
userService.login("admin", "123456");
userService.login("player1", "123456");
userService.login("admin", "wrongpassword");
}
}
Loading…
Cancel
Save