parent
00a453a922
commit
6b0ef53762
@ -0,0 +1,242 @@
|
||||
package self.cases.teams.teaa;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 定义缴费记录类
|
||||
class PaymentRecord {
|
||||
private String recordId;
|
||||
private String studentId;
|
||||
private String clubId;
|
||||
private double amount;
|
||||
private LocalDate paymentDate;
|
||||
private boolean isPaid;
|
||||
|
||||
public PaymentRecord(String recordId, String studentId, String clubId, double amount, LocalDate paymentDate, boolean isPaid) {
|
||||
this.recordId = recordId;
|
||||
this.studentId = studentId;
|
||||
this.clubId = clubId;
|
||||
this.amount = amount;
|
||||
this.paymentDate = paymentDate;
|
||||
this.isPaid = isPaid;
|
||||
}
|
||||
|
||||
public String getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
public void setRecordId(String recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public String getStudentId() {
|
||||
return studentId;
|
||||
}
|
||||
|
||||
public void setStudentId(String studentId) {
|
||||
this.studentId = studentId;
|
||||
}
|
||||
|
||||
public String getClubId() {
|
||||
return clubId;
|
||||
}
|
||||
|
||||
public void setClubId(String clubId) {
|
||||
this.clubId = clubId;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public LocalDate getPaymentDate() {
|
||||
return paymentDate;
|
||||
}
|
||||
|
||||
public void setPaymentDate(LocalDate paymentDate) {
|
||||
this.paymentDate = paymentDate;
|
||||
}
|
||||
|
||||
public boolean isPaid() {
|
||||
return isPaid;
|
||||
}
|
||||
|
||||
public void setPaid(boolean paid) {
|
||||
isPaid = paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PaymentRecord{" +
|
||||
"recordId='" + recordId + '\\' +
|
||||
", studentId='" + studentId + '\\' +
|
||||
", clubId='" + clubId + '\\' +
|
||||
", amount=" + amount +
|
||||
", paymentDate=" + paymentDate +
|
||||
", isPaid=" + isPaid +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
// 社团管理系统查询缴费记录类
|
||||
public class STcx {
|
||||
// 模拟数据库
|
||||
private List<PaymentRecord> payments = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
// 查询缴费记录
|
||||
private PaymentRecord findPaymentById(String recordId) {
|
||||
for (PaymentRecord payment : payments) {
|
||||
if (payment.getRecordId().equals(recordId)) {
|
||||
System.out.println("缴费记录查找成功: " + payment);
|
||||
return payment;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到缴费ID: " + recordId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<PaymentRecord> findPaymentsByStudentId(String studentId) {
|
||||
List<PaymentRecord> foundPayments = new ArrayList<>();
|
||||
for (PaymentRecord payment : payments) {
|
||||
if (payment.getStudentId().equals(studentId)) {
|
||||
foundPayments.add(payment);
|
||||
}
|
||||
}
|
||||
if (!foundPayments.isEmpty()) {
|
||||
System.out.println("找到缴费记录: ");
|
||||
for (PaymentRecord payment : foundPayments) {
|
||||
System.out.println(payment);
|
||||
}
|
||||
return foundPayments;
|
||||
} else {
|
||||
System.out.println("未找到学生ID: " + studentId);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
private List<PaymentRecord> findPaymentsByClubId(String clubId) {
|
||||
List<PaymentRecord> foundPayments = new ArrayList<>();
|
||||
for (PaymentRecord payment : payments) {
|
||||
if (payment.getClubId().equals(clubId)) {
|
||||
foundPayments.add(payment);
|
||||
}
|
||||
}
|
||||
if (!foundPayments.isEmpty()) {
|
||||
System.out.println("找到缴费记录: ");
|
||||
for (PaymentRecord payment : foundPayments) {
|
||||
System.out.println(payment);
|
||||
}
|
||||
return foundPayments;
|
||||
} else {
|
||||
System.out.println("未找到社团ID: " + clubId);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
// 删除缴费记录
|
||||
public boolean deletePayment(String recordId) {
|
||||
PaymentRecord paymentToRemove = findPaymentById(recordId);
|
||||
if (paymentToRemove != null) {
|
||||
payments.remove(paymentToRemove);
|
||||
System.out.println("缴费记录删除成功: " + paymentToRemove);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到缴费ID: " + recordId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新缴费记录
|
||||
public boolean updatePayment(String recordId, String field, Object newValue) {
|
||||
PaymentRecord paymentToUpdate = findPaymentById(recordId);
|
||||
if (paymentToUpdate != null) {
|
||||
switch (field.toLowerCase()) {
|
||||
case "amount":
|
||||
try {
|
||||
paymentToUpdate.setAmount(Double.parseDouble(newValue.toString()));
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("无效金额: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "ispaid":
|
||||
try {
|
||||
paymentToUpdate.setPaid(Boolean.parseBoolean(newValue.toString()));
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效支付状态: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("无效字段: " + field);
|
||||
return false;
|
||||
}
|
||||
System.out.println("缴费记录更新成功: " + paymentToUpdate);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到缴费ID: " + recordId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示所有缴费记录
|
||||
public void displayAllPayments() {
|
||||
if (payments.isEmpty()) {
|
||||
System.out.println("当前没有缴费记录");
|
||||
} else {
|
||||
System.out.println("所有缴费记录:");
|
||||
for (PaymentRecord payment : payments) {
|
||||
System.out.println(payment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理新缴费记录添加
|
||||
public boolean addNewPayment(String studentId, String clubId, double amount) {
|
||||
return addNewPayment(studentId, clubId, amount);
|
||||
}
|
||||
|
||||
// 生成唯一的ID
|
||||
private String generateUniqueId() {
|
||||
return "PAY" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// 主方法演示功能
|
||||
public static void main(String[] args) {
|
||||
STcx manager = new STcx();
|
||||
|
||||
// 添加新的缴费记录
|
||||
manager.addNewPayment("STD1", "CLB1", 50.0);
|
||||
manager.addNewPayment("STD2", "CLB2", 75.0);
|
||||
manager.addNewPayment("STD3", "CLB3", 100.0);
|
||||
manager.addNewPayment("STD4", "CLB4", 125.0);
|
||||
|
||||
// 显示所有缴费记录
|
||||
manager.displayAllPayments();
|
||||
|
||||
// 查询缴费记录
|
||||
manager.findPaymentsByStudentId("STD2");
|
||||
manager.findPaymentsByClubId("CLB3");
|
||||
|
||||
// 更新缴费记录
|
||||
manager.updatePayment("PAY1", "amount", 60.0);
|
||||
manager.updatePayment("PAY2", "ispaid", true);
|
||||
|
||||
// 再次显示所有缴费记录
|
||||
manager.displayAllPayments();
|
||||
|
||||
// 删除缴费记录
|
||||
manager.deletePayment("PAY2");
|
||||
|
||||
// 再次显示所有缴费记录
|
||||
manager.displayAllPayments();
|
||||
}
|
||||
}
|
@ -0,0 +1,247 @@
|
||||
package self.cases.teams.teaa;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 定义社团活动信息类
|
||||
class ActivityInfo {
|
||||
private String activityId;
|
||||
private String clubId;
|
||||
private String title;
|
||||
private String description;
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
private boolean isApproved;
|
||||
|
||||
public ActivityInfo(String activityId, String clubId, String title, String description, LocalDate startDate, LocalDate endDate, boolean isApproved) {
|
||||
this.activityId = activityId;
|
||||
this.clubId = clubId;
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.isApproved = isApproved;
|
||||
}
|
||||
|
||||
public String getActivityId() {
|
||||
return activityId;
|
||||
}
|
||||
|
||||
public void setActivityId(String activityId) {
|
||||
this.activityId = activityId;
|
||||
}
|
||||
|
||||
public String getClubId() {
|
||||
return clubId;
|
||||
}
|
||||
|
||||
public void setClubId(String clubId) {
|
||||
this.clubId = clubId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(LocalDate startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public boolean isApproved() {
|
||||
return isApproved;
|
||||
}
|
||||
|
||||
public void setApproved(boolean approved) {
|
||||
isApproved = approved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActivityInfo{" +
|
||||
"activityId='" + activityId + '\\' +
|
||||
", clubId='" + clubId + '\\' +
|
||||
", title='" + title + '\\' +
|
||||
", description='" + description + '\\' +
|
||||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", isApproved=" + isApproved +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
// 社团管理系统社团活动信息管理类
|
||||
public class SThd {
|
||||
// 模拟数据库
|
||||
private List<ActivityInfo> activities = new ArrayList<>();
|
||||
|
||||
|
||||
// 查询社团活动信息
|
||||
private ActivityInfo findActivityById(String activityId) {
|
||||
for (ActivityInfo activity : activities) {
|
||||
if (activity.getActivityId().equals(activityId)) {
|
||||
System.out.println("社团活动查找成功: " + activity);
|
||||
return activity;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到社团活动ID: " + activityId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private ActivityInfo findActivityByTitle(String title) {
|
||||
for (ActivityInfo activity : activities) {
|
||||
if (activity.getTitle().equals(title)) {
|
||||
System.out.println("社团活动查找成功: " + activity);
|
||||
return activity;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到社团活动标题: " + title);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 删除社团活动信息
|
||||
public boolean deleteActivity(String activityId) {
|
||||
ActivityInfo activityToRemove = findActivityById(activityId);
|
||||
if (activityToRemove != null) {
|
||||
activities.remove(activityToRemove);
|
||||
System.out.println("社团活动删除成功: " + activityToRemove);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到社团活动ID: " + activityId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新社团活动信息
|
||||
public boolean updateActivity(String activityId, String field, Object newValue) {
|
||||
ActivityInfo activityToUpdate = findActivityById(activityId);
|
||||
if (activityToUpdate != null) {
|
||||
switch (field.toLowerCase()) {
|
||||
case "title":
|
||||
activityToUpdate.setTitle(newValue.toString());
|
||||
break;
|
||||
case "description":
|
||||
activityToUpdate.setDescription(newValue.toString());
|
||||
break;
|
||||
case "startdate":
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate startDate = LocalDate.parse(newValue.toString(), formatter);
|
||||
activityToUpdate.setStartDate(startDate);
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效的开始日期: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "enddate":
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate endDate = LocalDate.parse(newValue.toString(), formatter);
|
||||
activityToUpdate.setEndDate(endDate);
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效的结束日期: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "approved":
|
||||
try {
|
||||
activityToUpdate.setApproved(Boolean.parseBoolean(newValue.toString()));
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效的批准状态: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("无效字段: " + field);
|
||||
return false;
|
||||
}
|
||||
System.out.println("社团活动信息更新成功: " + activityToUpdate);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到社团活动ID: " + activityId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示所有社团活动信息
|
||||
public void displayAllActivities() {
|
||||
if (activities.isEmpty()) {
|
||||
System.out.println("当前没有社团活动记录");
|
||||
} else {
|
||||
System.out.println("所有社团活动信息:");
|
||||
for (ActivityInfo activity : activities) {
|
||||
System.out.println(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理新社团活动添加
|
||||
public boolean addNewActivity(String clubId, String title, String description, String startDateStr, String endDateStr) {
|
||||
return addNewActivity(clubId, title, description, startDateStr, endDateStr);
|
||||
}
|
||||
|
||||
// 生成唯一的ID
|
||||
private String generateUniqueId() {
|
||||
return "ACT" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// 主方法演示功能
|
||||
public static void main(String[] args) {
|
||||
SThd manager = new SThd();
|
||||
|
||||
// 添加新的社团活动信息
|
||||
manager.addNewActivity("CLB1", "Sports Event", "Annual sports event", "2023-11-01", "2023-11-05");
|
||||
manager.addNewActivity("CLB2", "Music Festival", "Annual music festival", "2023-11-10", "2023-11-15");
|
||||
manager.addNewActivity("CLB3", "Art Exhibition", "Annual art exhibition", "2023-11-20", "2023-11-25");
|
||||
|
||||
// 显示所有社团活动信息
|
||||
manager.displayAllActivities();
|
||||
|
||||
// 处理新社团活动添加
|
||||
manager.addNewActivity("CLB4", "Science Fair", "Annual science fair", "2023-11-30", "2023-12-05");
|
||||
|
||||
// 再次显示所有社团活动信息
|
||||
manager.displayAllActivities();
|
||||
|
||||
// 更新社团活动信息
|
||||
manager.updateActivity("ACT1", "title", "Sports Event Updated");
|
||||
manager.updateActivity("ACT2", "startdate", "2023-11-11");
|
||||
manager.updateActivity("ACT3", "enddate", "2023-11-26");
|
||||
manager.updateActivity("ACT4", "approved", true);
|
||||
|
||||
// 再次显示所有社团活动信息
|
||||
manager.displayAllActivities();
|
||||
|
||||
// 删除社团活动信息
|
||||
manager.deleteActivity("ACT2");
|
||||
|
||||
// 再次显示所有社团活动信息
|
||||
manager.displayAllActivities();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,215 @@
|
||||
package self.cases.teams.teaa;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 定义通知信息类
|
||||
class NotificationInfo {
|
||||
private String notificationId;
|
||||
private String clubId;
|
||||
private String title;
|
||||
private String content;
|
||||
private LocalDateTime createdAt;
|
||||
private boolean isRead;
|
||||
|
||||
public NotificationInfo(String notificationId, String clubId, String title, String content, LocalDateTime createdAt, boolean isRead) {
|
||||
this.notificationId = notificationId;
|
||||
this.clubId = clubId;
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
this.createdAt = createdAt;
|
||||
this.isRead = isRead;
|
||||
}
|
||||
|
||||
public String getNotificationId() {
|
||||
return notificationId;
|
||||
}
|
||||
|
||||
public void setNotificationId(String notificationId) {
|
||||
this.notificationId = notificationId;
|
||||
}
|
||||
|
||||
public String getClubId() {
|
||||
return clubId;
|
||||
}
|
||||
|
||||
public void setClubId(String clubId) {
|
||||
this.clubId = clubId;
|
||||
}
|
||||
|
||||
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 LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return isRead;
|
||||
}
|
||||
|
||||
public void setRead(boolean read) {
|
||||
isRead = read;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NotificationInfo{" +
|
||||
"notificationId='" + notificationId + '\\' +
|
||||
", clubId='" + clubId + '\\' +
|
||||
", title='" + title + '\\' +
|
||||
", content='" + content + '\\' +
|
||||
", createdAt=" + createdAt +
|
||||
", isRead=" + isRead +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
// 社团管理系统通知信息管理类
|
||||
public class STtz {
|
||||
// 模拟数据库
|
||||
private List<NotificationInfo> notifications = new ArrayList<>();
|
||||
|
||||
// 查询通知信息
|
||||
private NotificationInfo findNotificationById(String notificationId) {
|
||||
for (NotificationInfo notification : notifications) {
|
||||
if (notification.getNotificationId().equals(notificationId)) {
|
||||
System.out.println("通知信息查找成功: " + notification);
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到通知ID: " + notificationId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private NotificationInfo findNotificationByTitle(String title) {
|
||||
for (NotificationInfo notification : notifications) {
|
||||
if (notification.getTitle().equals(title)) {
|
||||
System.out.println("通知信息查找成功: " + notification);
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到通知标题: " + title);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 删除通知信息
|
||||
public boolean deleteNotification(String notificationId) {
|
||||
NotificationInfo notificationToRemove = findNotificationById(notificationId);
|
||||
if (notificationToRemove != null) {
|
||||
notifications.remove(notificationToRemove);
|
||||
System.out.println("通知信息删除成功: " + notificationToRemove);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到通知ID: " + notificationId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新通知信息
|
||||
public boolean updateNotification(String notificationId, String field, Object newValue) {
|
||||
NotificationInfo notificationToUpdate = findNotificationById(notificationId);
|
||||
if (notificationToUpdate != null) {
|
||||
switch (field.toLowerCase()) {
|
||||
case "title":
|
||||
notificationToUpdate.setTitle(newValue.toString());
|
||||
break;
|
||||
case "content":
|
||||
notificationToUpdate.setContent(newValue.toString());
|
||||
break;
|
||||
case "isread":
|
||||
try {
|
||||
notificationToUpdate.setRead(Boolean.parseBoolean(newValue.toString()));
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效的阅读状态: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("无效字段: " + field);
|
||||
return false;
|
||||
}
|
||||
System.out.println("通知信息更新成功: " + notificationToUpdate);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到通知ID: " + notificationId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示所有通知信息
|
||||
public void displayAllNotifications() {
|
||||
if (notifications.isEmpty()) {
|
||||
System.out.println("当前没有通知记录");
|
||||
} else {
|
||||
System.out.println("所有通知信息:");
|
||||
for (NotificationInfo notification : notifications) {
|
||||
System.out.println(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理新通知添加
|
||||
public boolean addNewNotification(String clubId, String title, String content) {
|
||||
return addNewNotification(clubId, title, content);
|
||||
}
|
||||
|
||||
// 生成唯一的ID
|
||||
private String generateUniqueId() {
|
||||
return "NOT" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// 主方法演示功能
|
||||
public static void main(String[] args) {
|
||||
STtz manager = new STtz();
|
||||
|
||||
// 添加新的通知信息
|
||||
manager.addNewNotification("CLB1", "Meeting Reminder", "Please attend the meeting tomorrow at 3 PM.");
|
||||
manager.addNewNotification("CLB2", "Event Update", "The event has been postponed to next week.");
|
||||
manager.addNewNotification("CLB3", "Important Announcement", "A new policy will be implemented starting next month.");
|
||||
|
||||
// 显示所有通知信息
|
||||
manager.displayAllNotifications();
|
||||
|
||||
// 处理新通知添加
|
||||
manager.addNewNotification("CLB4", "Volunteer Opportunity", "We need volunteers for the upcoming event.");
|
||||
|
||||
// 再次显示所有通知信息
|
||||
manager.displayAllNotifications();
|
||||
|
||||
// 更新通知信息
|
||||
manager.updateNotification("NOT1", "title", "Updated Meeting Reminder");
|
||||
manager.updateNotification("NOT2", "content", "The event has been postponed to next Friday.");
|
||||
manager.updateNotification("NOT3", "isread", true);
|
||||
manager.updateNotification("NOT4", "isread", false);
|
||||
|
||||
// 再次显示所有通知信息
|
||||
manager.displayAllNotifications();
|
||||
|
||||
// 删除通知信息
|
||||
manager.deleteNotification("NOT2");
|
||||
|
||||
// 再次显示所有通知信息
|
||||
manager.displayAllNotifications();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,206 @@
|
||||
package self.cases.teams.teaa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 定义社团类型信息类
|
||||
class ClubType {
|
||||
private String typeId;
|
||||
private String typeName;
|
||||
private String description;
|
||||
private int capacity;
|
||||
private boolean isActive;
|
||||
|
||||
public ClubType(String typeId, String typeName, String description, int capacity, boolean isActive) {
|
||||
this.typeId = typeId;
|
||||
this.typeName = typeName;
|
||||
this.description = description;
|
||||
this.capacity = capacity;
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public String getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public void setCapacity(int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClubType{" +
|
||||
"typeId='" + typeId + '\\' +
|
||||
", typeName='" + typeName + '\\' +
|
||||
", description='" + description + '\\' +
|
||||
", capacity=" + capacity +
|
||||
", isActive=" + isActive +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
// 社团管理系统社团类型管理类
|
||||
public class STxtlx {
|
||||
// 模拟数据库
|
||||
private List<ClubType> clubTypes = new ArrayList<>();
|
||||
|
||||
|
||||
// 查询社团类型
|
||||
private ClubType findClubTypeById(String typeId) {
|
||||
for (ClubType clubType : clubTypes) {
|
||||
if (clubType.getTypeId().equals(typeId)) {
|
||||
System.out.println("社团类型查找成功: " + clubType);
|
||||
return clubType;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到社团类型ID: " + typeId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private ClubType findClubTypeByName(String typeName) {
|
||||
for (ClubType clubType : clubTypes) {
|
||||
if (clubType.getTypeName().equals(typeName)) {
|
||||
System.out.println("社团类型查找成功: " + clubType);
|
||||
return clubType;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到社团类型名称: " + typeName);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 删除社团类型
|
||||
public boolean deleteClubType(String typeId) {
|
||||
ClubType clubTypeToRemove = findClubTypeById(typeId);
|
||||
if (clubTypeToRemove != null) {
|
||||
clubTypes.remove(clubTypeToRemove);
|
||||
System.out.println("社团类型删除成功: " + clubTypeToRemove);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到社团类型ID: " + typeId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新社团类型信息
|
||||
public boolean updateClubType(String typeId, String field, Object newValue) {
|
||||
ClubType clubTypeToUpdate = findClubTypeById(typeId);
|
||||
if (clubTypeToUpdate != null) {
|
||||
switch (field.toLowerCase()) {
|
||||
case "typename":
|
||||
clubTypeToUpdate.setTypeName(newValue.toString());
|
||||
break;
|
||||
case "description":
|
||||
clubTypeToUpdate.setDescription(newValue.toString());
|
||||
break;
|
||||
case "capacity":
|
||||
try {
|
||||
clubTypeToUpdate.setCapacity(Integer.parseInt(newValue.toString()));
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("无效的容量值: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "active":
|
||||
try {
|
||||
clubTypeToUpdate.setActive(Boolean.parseBoolean(newValue.toString()));
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效的活动状态: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("无效字段: " + field);
|
||||
return false;
|
||||
}
|
||||
System.out.println("社团类型信息更新成功: " + clubTypeToUpdate);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到社团类型ID: " + typeId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示所有社团类型信息
|
||||
public void displayAllClubTypes() {
|
||||
if (clubTypes.isEmpty()) {
|
||||
System.out.println("当前没有社团类型记录");
|
||||
} else {
|
||||
System.out.println("所有社团类型信息:");
|
||||
for (ClubType clubType : clubTypes) {
|
||||
System.out.println(clubType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理新社团类型添加
|
||||
public boolean addNewClubType(String typeName, String description, int capacity) {
|
||||
return addNewClubType(typeName, description, capacity);
|
||||
}
|
||||
|
||||
// 生成唯一的ID
|
||||
private String generateUniqueId() {
|
||||
return "CLT" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// 主方法演示功能
|
||||
public static void main(String[] args) {
|
||||
STxtlx manager = new STxtlx();
|
||||
|
||||
// 添加新的社团类型
|
||||
manager.addNewClubType("Sports", "Sports Club", 50);
|
||||
manager.addNewClubType("Music", "Music Club", 30);
|
||||
manager.addNewClubType("Art", "Art Club", 20);
|
||||
|
||||
// 显示所有社团类型信息
|
||||
manager.displayAllClubTypes();
|
||||
|
||||
// 处理新社团类型添加
|
||||
manager.addNewClubType("Science", "Science Club", 40);
|
||||
|
||||
// 再次显示所有社团类型信息
|
||||
manager.displayAllClubTypes();
|
||||
|
||||
// 更新社团类型信息
|
||||
manager.updateClubType("CLT1", "typename", "Sports Club Updated");
|
||||
manager.updateClubType("CLT2", "capacity", 35);
|
||||
manager.updateClubType("CLT3", "active", false);
|
||||
|
||||
// 再次显示所有社团类型信息
|
||||
manager.displayAllClubTypes();
|
||||
|
||||
// 删除社团类型
|
||||
manager.deleteClubType("CLT2");
|
||||
|
||||
// 再次显示所有社团类型信息
|
||||
manager.displayAllClubTypes();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,220 @@
|
||||
package self.cases.teams.teaa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// 定义社团信息类
|
||||
class ClubInfo {
|
||||
private String clubId;
|
||||
private String clubName;
|
||||
private String type;
|
||||
private String president;
|
||||
private int memberCount;
|
||||
private boolean isActive;
|
||||
|
||||
public ClubInfo(String clubId, String clubName, String type, String president, int memberCount, boolean isActive) {
|
||||
this.clubId = clubId;
|
||||
this.clubName = clubName;
|
||||
this.type = type;
|
||||
this.president = president;
|
||||
this.memberCount = memberCount;
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public String getClubId() {
|
||||
return clubId;
|
||||
}
|
||||
|
||||
public String getClubName() {
|
||||
return clubName;
|
||||
}
|
||||
|
||||
public void setClubName(String clubName) {
|
||||
this.clubName = clubName;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPresident() {
|
||||
return president;
|
||||
}
|
||||
|
||||
public void setPresident(String president) {
|
||||
this.president = president;
|
||||
}
|
||||
|
||||
public int getMemberCount() {
|
||||
return memberCount;
|
||||
}
|
||||
|
||||
public void setMemberCount(int memberCount) {
|
||||
this.memberCount = memberCount;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClubInfo{" +
|
||||
"clubId='" + clubId + '\\' +
|
||||
", clubName='" + clubName + '\\' +
|
||||
", type='" + type + '\\' +
|
||||
", president='" + president + '\\' +
|
||||
", memberCount=" + memberCount +
|
||||
", isActive=" + isActive +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
// 社团管理系统社团信息管理类
|
||||
public class STxtxx {
|
||||
// 模拟数据库
|
||||
private List<ClubInfo> clubs = new ArrayList<>();
|
||||
|
||||
|
||||
// 查询社团信息
|
||||
private ClubInfo findClubById(String clubId) {
|
||||
for (ClubInfo club : clubs) {
|
||||
if (club.getClubId().equals(clubId)) {
|
||||
System.out.println("社团查找成功: " + club);
|
||||
return club;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到社团ID: " + clubId);
|
||||
return null;
|
||||
}
|
||||
|
||||
private ClubInfo findClubByName(String clubName) {
|
||||
for (ClubInfo club : clubs) {
|
||||
if (club.getClubName().equals(clubName)) {
|
||||
System.out.println("社团查找成功: " + club);
|
||||
return club;
|
||||
}
|
||||
}
|
||||
System.out.println("未找到社团名称: " + clubName);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 删除社团信息
|
||||
public boolean deleteClub(String clubId) {
|
||||
ClubInfo clubToRemove = findClubById(clubId);
|
||||
if (clubToRemove != null) {
|
||||
clubs.remove(clubToRemove);
|
||||
System.out.println("社团删除成功: " + clubToRemove);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到社团ID: " + clubId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 更新社团信息
|
||||
public boolean updateClub(String clubId, String field, Object newValue) {
|
||||
ClubInfo clubToUpdate = findClubById(clubId);
|
||||
if (clubToUpdate != null) {
|
||||
switch (field.toLowerCase()) {
|
||||
case "clubname":
|
||||
clubToUpdate.setClubName(newValue.toString());
|
||||
break;
|
||||
case "type":
|
||||
clubToUpdate.setType(newValue.toString());
|
||||
break;
|
||||
case "president":
|
||||
clubToUpdate.setPresident(newValue.toString());
|
||||
break;
|
||||
case "membercount":
|
||||
try {
|
||||
clubToUpdate.setMemberCount(Integer.parseInt(newValue.toString()));
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("无效的会员人数值: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "active":
|
||||
try {
|
||||
clubToUpdate.setActive(Boolean.parseBoolean(newValue.toString()));
|
||||
} catch (Exception e) {
|
||||
System.out.println("无效的活动状态: " + newValue);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("无效字段: " + field);
|
||||
return false;
|
||||
}
|
||||
System.out.println("社团信息更新成功: " + clubToUpdate);
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("未找到社团ID: " + clubId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示所有社团信息
|
||||
public void displayAllClubs() {
|
||||
if (clubs.isEmpty()) {
|
||||
System.out.println("当前没有社团记录");
|
||||
} else {
|
||||
System.out.println("所有社团信息:");
|
||||
for (ClubInfo club : clubs) {
|
||||
System.out.println(club);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理新社团添加
|
||||
public boolean addNewClub(String clubName, String type, String president, int memberCount) {
|
||||
return addNewClub(clubName, type, president, memberCount);
|
||||
}
|
||||
|
||||
// 生成唯一的ID
|
||||
private String generateUniqueId() {
|
||||
return "CLB" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// 主方法演示功能
|
||||
public static void main(String[] args) {
|
||||
STxtxx manager = new STxtxx();
|
||||
|
||||
// 添加新的社团信息
|
||||
manager.addNewClub("Sports Club", "Sports", "John Doe", 50);
|
||||
manager.addNewClub("Music Club", "Music", "Jane Smith", 30);
|
||||
manager.addNewClub("Art Club", "Art", "Alice Johnson", 20);
|
||||
|
||||
// 显示所有社团信息
|
||||
manager.displayAllClubs();
|
||||
|
||||
// 处理新社团添加
|
||||
manager.addNewClub("Science Club", "Science", "Bob Brown", 40);
|
||||
|
||||
// 再次显示所有社团信息
|
||||
manager.displayAllClubs();
|
||||
|
||||
// 更新社团信息
|
||||
manager.updateClub("CLB1", "clubname", "Sports Club Updated");
|
||||
manager.updateClub("CLB2", "membercount", 35);
|
||||
manager.updateClub("CLB3", "active", false);
|
||||
|
||||
// 再次显示所有社团信息
|
||||
manager.displayAllClubs();
|
||||
|
||||
// 删除社团信息
|
||||
manager.deleteClub("CLB2");
|
||||
|
||||
// 再次显示所有社团信息
|
||||
manager.displayAllClubs();
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue