能够管理各参赛队伍的基本信息(包含参赛队编号,参赛作品名称,参赛学校,赛事类别,参赛者,指导老师);包含增加、删除、修改参赛队伍的信息用java实现
时间: 2023-07-16 10:13:35 浏览: 137
竞赛信息管理系统。管理员、教师、学生基本信息管理。对比赛记录,赛事信息的增删改查。并基于角色进行权限控制(RBAC).zip
好的,您可以这样实现:
首先,定义一个参赛队伍类,包含参赛队编号、参赛作品名称、参赛学校、赛事类别、参赛者、指导老师等属性及对应的get/set方法。
```
public class Team {
private String teamId; //参赛队编号
private String projectName; //参赛作品名称
private String school; //参赛学校
private String category; //赛事类别
private String participants; //参赛者
private String teacher; //指导老师
public Team(String teamId, String projectName, String school, String category, String participants, String teacher) {
this.teamId = teamId;
this.projectName = projectName;
this.school = school;
this.category = category;
this.participants = participants;
this.teacher = teacher;
}
//get/set方法
public String getTeamId() {
return teamId;
}
public void setTeamId(String teamId) {
this.teamId = teamId;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getSchool() {
return school;
}
public void setSchool(String school) {
this.school = school;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getParticipants() {
return participants;
}
public void setParticipants(String participants) {
this.participants = participants;
}
public String getTeacher() {
return teacher;
}
public void setTeacher(String teacher) {
this.teacher = teacher;
}
}
```
然后,定义一个参赛队伍管理类,包含增加、删除、修改参赛队伍的信息的方法。这里使用一个List集合来存储参赛队伍信息。
```
import java.util.ArrayList;
import java.util.List;
public class TeamManager {
private List<Team> teamList = new ArrayList<>();
//增加参赛队伍信息
public void addTeam(Team team) {
teamList.add(team);
}
//删除指定参赛队伍信息
public void deleteTeam(String teamId) {
for(Team team : teamList) {
if(team.getTeamId().equals(teamId)) {
teamList.remove(team);
break;
}
}
}
//修改指定参赛队伍信息
public void modifyTeam(String teamId, String projectName, String school, String category, String participants, String teacher) {
for(Team team : teamList) {
if(team.getTeamId().equals(teamId)) {
team.setProjectName(projectName);
team.setSchool(school);
team.setCategory(category);
team.setParticipants(participants);
team.setTeacher(teacher);
break;
}
}
}
//获取所有参赛队伍信息
public List<Team> getAllTeams() {
return teamList;
}
}
```
使用示例:
```
public static void main(String[] args) {
//创建参赛队伍管理类实例
TeamManager teamManager = new TeamManager();
//添加一支参赛队伍
Team team1 = new Team("001", "作品1", "学校1", "类别1", "参赛者1", "指导老师1");
teamManager.addTeam(team1);
//获取所有参赛队伍信息
List<Team> teamList = teamManager.getAllTeams();
for(Team team : teamList) {
System.out.println(team.getTeamId() + " " + team.getProjectName() + " " + team.getSchool() + " " + team.getCategory() + " " + team.getParticipants() + " " + team.getTeacher());
}
//修改一支参赛队伍信息
teamManager.modifyTeam("001", "作品2", "学校2", "类别2", "参赛者2", "指导老师2");
//获取所有参赛队伍信息
teamList = teamManager.getAllTeams();
for(Team team : teamList) {
System.out.println(team.getTeamId() + " " + team.getProjectName() + " " + team.getSchool() + " " + team.getCategory() + " " + team.getParticipants() + " " + team.getTeacher());
}
//删除一支参赛队伍信息
teamManager.deleteTeam("001");
//获取所有参赛队伍信息
teamList = teamManager.getAllTeams();
for(Team team : teamList) {
System.out.println(team.getTeamId() + " " + team.getProjectName() + " " + team.getSchool() + " " + team.getCategory() + " " + team.getParticipants() + " " + team.getTeacher());
}
}
```
注意,这里为了简化示例,省略了输入参数的校验。在实际开发中,需要对输入参数进行有效性校验,避免出现错误。
阅读全文