在我上个主题的期末作品设计中,涉及到的天空之城还没有完成,针对盆友的请求,对他给定的主题去设计了一个新的面向对象程序设计的主题系统——赛事信息管理系统
我给它分为了四个信息处理界面:1、老板的信息管理 2、俱乐部信息管理 3、团队信息管理 4、电竞选手信息管理
给了五个类的设计:1、boss 2、club 3、team 4、member 5、administrator
首先展示一下它的主方法里的内容
package EventInformationManagementSystem;
import EventInformationManagementSystem.ClassLayerControl.*;
import EventInformationManagementSystem.ControlLayer.bossInformationManagement;
import EventInformationManagementSystem.ControlLayer.clubInformationManagement;
import EventInformationManagementSystem.ControlLayer.memberInformationManagement;
import EventInformationManagementSystem.ControlLayer.teamInformationManagement;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Scanner;
/**
* YicStudio
*
* @ClassName类名: eventInformationManagementSystem
* @Description描述: 赛事信息管理系统
* @author编程者: 一冲子
* @date日期: 2022/12/22 16:32
* @Blog小猴子: https://blog.youkuaiyun.com/YIC020920/
* @Blog博客园: https://www.cnblogs.com/YICHONG-777/
*/
public class eventInformationManagementSystem {
public static void main(String[] args) {
/** 获取键盘输入 */
Scanner sc = new Scanner(System.in);
/** 创建俱乐部空列表,到时候可以用数据库代替 */
ArrayList<club> clubArray = new ArrayList<>();
/** 创建boss集合 */
ArrayList<boss> boss = new ArrayList<>();
/** 创建团队集合 */
ArrayList<team> team = new ArrayList<>();
/** 创建成员集合 */
ArrayList<member> members = new ArrayList<>();
System.out.println("欢迎来到崇华游戏中心~");
administrator administrator = new administrator(102355,"wch11");
System.out.println("请输入管理员账号:");
int adminId = sc.nextInt();
System.out.println("请输入管理员密码:");
String adminPwd = sc.next();
if (adminId==administrator.getId() && Objects.equals(adminPwd, administrator.getPwd())){
System.out.println("欢迎管理员回来!");
System.out.println("按1进入老板信息处理,按2进入俱乐部信息处理,按3进入俱乐部战队信息处理,按4进入战队成员信息处理,按0退出!");
while (true){
String c = sc.next();
if("1".equals(c)){
bossInformationManagement.ourBoss();
bossInformationManagement.menu();
while (sc.hasNextInt()){
int input = sc.nextInt();
if (input == 0){
break;
}
switch (input){
case 1:
// 录入新老板信息
bossInformationManagement.addBoss(boss);
break;
case 2:
// 修改老板信息及行程
bossInformationManagement.updateBoss(boss);
break;
case 3:
// 显示老板所有信息
bossInformationManagement.showBoss(boss);
break;
default:
System.out.println("输入无效!");
break;
}
System.out.println();
System.out.println();
System.out.println("array:"+boss);
bossInformationManagement.menu();
}
System.out.println("退出boss日志!");
}else if ("2".equals(c)){
clubInformationManagement.menu();
while (sc.hasNextInt()){
int input = sc.nextInt();
if (input == 5){
break;
}
switch (input){
case 1:
// 新增参赛俱乐部
clubInformationManagement.addClub(clubArray);
break;
case 2:
// 查询参赛俱乐部
clubInformationManagement.findClub(clubArray);
break;
case 3:
// 删除
clubInformationManagement.deleteClub(clubArray);
break;
case 4:
// 显示参赛俱乐部信息
clubInformationManagement.showClub(clubArray);
break;
default:
System.out.println("输入无效!");
break;
}
System.out.println();
System.out.println();
System.out.println("array:"+clubArray);
clubInformationManagement.menu();
}
System.out.println("崇华赛事信息管理管理系统!");
}else if ("3".equals(c)){
teamInformationManagement.menu();
while (sc.hasNextInt()){
int input = sc.nextInt();
if (input == 0){
break;
}
switch (input){
case 1:
// 新增参赛战队
teamInformationManagement.addTeam(team);
break;
case 2:
// 查询参赛战队
teamInformationManagement.findTeam(team);
break;
case 3:
// 删除
teamInformationManagement.deleteTeam(team);
break;
case 4:
// 显示参赛战队信息
teamInformationManagement.showTeam(team);
break;
default:
System.out.println("输入无效!");
break;
}
System.out.println();
System.out.println();
System.out.println("array:"+team);
teamInformationManagement.menu();
}
System.out.println("战队信息处理完毕!");
}else if ("4".equals(c)){
memberInformationManagement.menu();
while (sc.hasNextInt()){
int input = sc.nextInt();
if (input == 0){
break;
}
switch (input){
case 1:
// 新增选手
memberInformationManagement.addMember(members);
break;
case 2:
// 查询参赛选手
memberInformationManagement.findMember(members);
break;
case 3:
// 删除
memberInformationManagement.deleteMember(members);
break;
case 4:
// 显示参赛选手信息
memberInformationManagement.showMember(members);
break;
default:
System.out.println("输入无效!");
break;
}
System.out.println();
System.out.println();
System.out.println("array:"+members);
memberInformationManagement.menu();
}
System.out.println("选手信息处理完毕!");
}
}
}
}
}
然后是4大界面模块
一、bossInformationManagement
package EventInformationManagementSystem.ControlLayer;
import EventInformationManagementSystem.ClassLayerControl.boss;
import java.util.ArrayList;
import java.util.Scanner;
/**
* YicStudio
*
* @ClassName类名: bossInformationManagement
* @Description描述: 老板的信息管理
* @author编程者: 一冲子
* @date日期: 2022/12/27 22:28
* @Blog小猴子: https://blog.youkuaiyun.com/YIC020920/
* @Blog博客园: https://www.cnblogs.com/YICHONG-777/
*/
public class bossInformationManagement {
public static void ourBoss(){
boss b = new boss("小花",999,38,"拿下西部大厂");
System.out.println(b);
}
public static void menu(){
System.out.println("==============崇华游戏集团公司=============\n" +
">>>1、录入老板信息及行程\n" +
">>>2、修改老板信息及行程\n" +
">>>3、显示老板所有信息\n" +
">>>0、退出boss日志\n" +
"==============崇华赛事信息管理欢迎使用=============");
System.out.print("请根据要求输入相关功能所属编号:");
}
public static void addBoss(ArrayList<boss> boss){
Scanner sc = new Scanner(System.in);
System.out.print("请输入老板姓名:");
String name = sc.next();
System.out.println("请输入老板实时身价:");
int worth = sc.nextInt();
System.out.println("请输入老板的年龄:");
int age = sc.nextInt();
System.out.print("请输入老板的行程:");
String itinerary = sc.next();
// 将信息保存到集合中
boss b = new boss();
b.setBossName(name);
b.setBossAge(age);
b.setBossWorth(worth);
b.setItinerary(itinerary);
// 将俱乐部对象给到集合中
boss.add(b);
System.out.print("添加成功!");
}
/** 修改老板的信息 */
public static void updateBoss(ArrayList<boss> boss) {
// 键盘输入要修改的老板名字,显示提示信息
Scanner sc = new Scanner(System.in);
System.out.println("请输入老板的名字:");
String name = sc.next();
int index = -1;
// 遍历结合修改老板的对应信息
for(int i = 0; i < boss.size(); i++){
boss b = boss.get(i);
if (b.getBossName().equals(name)){
index = i;
break;
}
}
if (index == -1) {
System.out.println("你是不是输入错误了?还是咱老板不是这个?");
} else {
System.out.print("请重新输入老板姓名:");
String newName = sc.next();
System.out.println("请更新老板的实时身价:");
int worth = sc.nextInt();
System.out.println("请重新输入老板的年龄:");
int age = sc.nextInt();
System.out.print("请输入老板的行程:");
String itinerary = sc.next();
// 将信息保存到集合中
boss b = new boss();
b.setBossName(newName);
b.setBossAge(age);
b.setBossWorth(worth);
b.setItinerary(itinerary);
boss.set(index, b);
// 给出修改成功提示
System.out.println("已成功更新老板的信息!");
}
}
public static void showBoss(ArrayList<boss> boss){
//展示所有俱乐部信息
System.out.println("姓名\t\t身价\t\t年龄\t\t行程");
for (int i = 0; i < boss.size(); i++) {
boss b = boss.get(i);
System.out.println(b.getBossName()+"\t\t"+b.getBossWorth()+"\t\t"+b.getBossAge()+"\t\t"+b.getItinerary());
}
}
}
二、clubInformationManagement
package EventInformationManagementSystem.ControlLayer;
import EventInformationManagementSystem.ClassLayerControl.club;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Scanner;
/**
* YicStudio
*
* @ClassName类名: clubInformationManagement
* @Description描述: 俱乐部信息管理
* @author编程者: 一冲子
* @date日期: 2022/12/27 16:32
* @Blog小猴子: https://blog.youkuaiyun.com/YIC020920/
* @Blog博客园: https://www.cnblogs.com/YICHONG-777/
*/
public class clubInformationManagement{
public static void menu(){
System.out.println("==============崇华赛事信息管理管理中心=============\n" +
">>>1、新增俱乐部\n" +
">>>2、查询俱乐部(根据编号查询)\n" +
">>>3、删除违规及退赛俱乐部\n" +
">>>4、显示所有俱乐部信息\n" +
">>>5、退出俱乐部管理操作系统\n" +
"==============崇华赛事信息管理欢迎使用=============");
System.out.print("请根据要求输入相关功能所属编号:");
}
public static boolean isUesd(ArrayList<club> clubArray, int id){
//遍历进行比较,有相同返回true,否则返回fales
boolean flg = false;
for (int i = 0; i < clubArray.size(); i++) {
club club = clubArray.get(i);
if (Objects.equals(club.getId(), id)){
flg = true;
break;
}
}
return flg;
}
public static void addClub(ArrayList<club> clubArray){
Scanner sc = new Scanner(System.in);
// 后面要通过俱乐部编号进行信息查找,所以要求编号不能重复
int id ;
while (true) {
System.out.println("请输入编号:");
id = sc.nextInt();
// 定义一个判断方法
boolean flg = isUesd(clubArray, id);
if (flg) {
System.out.println("此编号已被使用,请重新输入!");
} else {
break; //当编号有效时,跳出循环
}
}
System.out.println("请输入俱乐部参赛编号:");
int clubId = sc.nextInt();
System.out.println("请输入俱乐部名称:");
String clubName = sc.next();
System.out.println("请输入俱乐部游戏经营类型:");
String gameType = sc.next();
// 赋值给到俱乐部
club club_This = new club();
club_This.setId(clubId);
club_This.setName(clubName);
club_This.setGameType(gameType);
// 将俱乐部对象给到集合中
clubArray.add(club_This);
System.out.print("添加成功!");
}
public static void findClub(ArrayList<club> clubArray){
// 根据id查找俱乐部
Scanner sc = new Scanner(System.in);
System.out.println("输入查找要查找的俱乐部参赛编号:");
int id = sc.nextInt();
// 判断参赛是否存在并查找输出
int flg = -1; //定义一个判断标志,因为数组下标不会为-1.所以将flg初始化为-1
club club_f = new club();
for (int i = 0; i < clubArray.size(); i++) {
club_f = clubArray.get(i);
if(Objects.equals(club_f.getId(), id)){
flg = i;
break;
}
}
if (flg == -1){
System.out.println("该战队未参赛!");
}else{
System.out.println("找到战队!");
System.out.println("俱乐部参赛编号:"+club_f.getId()+"\t俱乐部名称:"+club_f.getName()+"\t俱乐部游戏经验类型:"+club_f.getGameType());
}
}
public static void deleteClub(ArrayList<club> clubArray){
// 删除违规俱乐部参赛资格
Scanner sc = new Scanner(System.in);
System.out.println("输入要删除的俱乐部名称:");
String name = sc.nextLine();
for (int i = 0; i < clubArray.size(); i++) {
if(clubArray.get(i).getName().equals(name)){
clubArray.remove(i);
break;
}
}
System.out.println("成功删除"+name+"的信息!");
}
public static void showClub(ArrayList<club> clubArray){
//展示所有俱乐部信息
System.out.println("俱乐部编号\t\t名称\t\t游戏经营类型");
for (int i = 0; i < clubArray.size(); i++) {
club s = clubArray.get(i);
System.out.println(s.getId()+"\t\t"+s.getName()+"\t\t"+s.getGameType());
}
}
}
三、teamInformationManagement
package EventInformationManagementSystem.ControlLayer;
import EventInformationManagementSystem.ClassLayerControl.team;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Scanner;
/**
* YicStudio
*
* @ClassName类名: teamInformationManagement
* @Description描述: 团队信息管理
* @author编程者: 一冲子
* @date日期: 2022/12/27 23:24
* @Blog小猴子: https://blog.youkuaiyun.com/YIC020920/
* @Blog博客园: https://www.cnblogs.com/YICHONG-777/
*/
public class teamInformationManagement {
public static void menu(){
System.out.println("==============崇华赛事信息管理管理中心=============\n" +
">>>1、录入参赛战队\n" +
">>>2、查询战队(根据编号查询)\n" +
">>>3、删除违规及退赛俱乐部旗下战队\n" +
">>>4、显示所有战队信息\n" +
">>>0、退出战队管理界面\n" +
"==============崇华赛事信息管理欢迎使用=============");
System.out.print("请根据要求输入相关功能所属编号:");
}
public static boolean isUesd(ArrayList<team> team, int id){
//遍历进行比较,有相同返回true,否则返回fales
boolean flg = false;
for (int i = 0; i < team.size(); i++) {
team t = team.get(i);
if (Objects.equals(t.getId(), id)){
flg = true;
break;
}
}
return flg;
}
public static void addTeam(ArrayList<team> team){
Scanner sc = new Scanner(System.in);
// 后面要通过俱乐部编号进行信息查找,所以要求编号不能重复
int id ;
while (true) {
System.out.println("请输入战队编号:");
id = sc.nextInt();
// 定义一个判断方法
boolean flg = isUesd(team, id);
if (flg) {
System.out.println("此编号已被使用,请重新输入!");
} else {
break; //当编号有效时,跳出循环
}
}
System.out.println("请输入参赛战队编号:");
int teamId = sc.nextInt();
System.out.println("请输入参赛战队名称:");
String teamName = sc.next();
System.out.println("请输入战队人数(最少5人,最多10人):");
int teamNum = sc.nextInt();
while (true){
if (teamNum<5 || teamNum>10){
System.out.println("战队最少5人,最多10人!");
}else {
break;
}
}
// 赋值给到team
team t = new team();
t.setId(teamId);
t.setName(teamName);
t.setNumber(teamNum);
// 将战队信息给到集合中
team.add(t);
System.out.print("添加成功!");
}
public static void findTeam(ArrayList<team> team){
// 根据id查找战队
Scanner sc = new Scanner(System.in);
System.out.println("输入需要查找的参赛战队编号:");
int id = sc.nextInt();
// 判断参赛是否存在并查找输出
int flg = -1; //定义一个判断标志,因为数组下标不会为-1.所以将flg初始化为-1
team team1 = new team();
for (int i = 0; i < team.size(); i++) {
team = team.get(i);
if(Objects.equals(team1.getId(), id)){
flg = i;
break;
}
}
if (flg == -1){
System.out.println("该战队未参赛!");
}else{
System.out.println("找到战队!");
System.out.println("战队参赛编号:"+team1.getId()+"\t战队名称:"+team1.getName()+"\t参赛人数:"+team1.getNumber());
}
}
public static void deleteTeam(ArrayList<team> team){
// 删除违规战队参赛资格
Scanner sc = new Scanner(System.in);
System.out.println("输入要删除的战队的参赛编号:");
int id = sc.nextInt();
for (int i = 0; i < team.size(); i++) {
if(Objects.equals(team.get(i).getId(), id)){
team.remove(i);
break;
}
}
System.out.println("成功删除战队编号为"+id+"的信息!");
}
public static void showTeam(ArrayList<team> team){
//展示所有俱乐部信息
System.out.println("战队编号\t\t名称\t\t参赛人数");
for (int i = 0; i < team.size(); i++) {
team t = team.get(i);
System.out.println(t.getId()+"\t\t"+t.getName()+"\t\t"+t.getNumber());
}
}
}
四、memberInformationManagement
package EventInformationManagementSystem.ControlLayer;
import EventInformationManagementSystem.ClassLayerControl.member;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Scanner;
/**
* YicStudio
*
* @ClassName类名: memberInformationManagement
* @Description描述: 电竞选手信息管理
* @author编程者: 一冲子
* @date日期: 2022/12/28 00:02
* @Blog小猴子: https://blog.youkuaiyun.com/YIC020920/
* @Blog博客园: https://www.cnblogs.com/YICHONG-777/
*/
public class memberInformationManagement {
public static void menu(){
System.out.println("==============崇华赛事信息管理管理中心=============\n" +
">>>1、录入成员信息\n" +
">>>2、查询成员(根据编号查询)\n" +
">>>3、删除违规及退赛选手\n" +
">>>4、显示所有电竞选手信息\n" +
">>>0、退出选手管理界面\n" +
"==============崇华赛事信息管理欢迎使用=============");
System.out.print("请根据要求输入相关功能所属编号:");
}
public static boolean isUesd(ArrayList<member> member, int id){
//遍历进行比较,有相同返回true,否则返回fales
boolean flg = false;
for (int i = 0; i < member.size(); i++) {
member m = member.get(i);
if (Objects.equals(m.getMemberId(), id)){
flg = true;
break;
}
}
return flg;
}
public static void addMember(ArrayList<member> member){
Scanner sc = new Scanner(System.in);
// 后面要通过俱乐部编号进行信息查找,所以要求编号不能重复
int id ;
while (true) {
System.out.println("请输入编号:");
id = sc.nextInt();
// 定义一个判断方法
boolean flg = isUesd(member, id);
if (flg) {
System.out.println("此编号已被使用,请重新输入!");
} else {
break; //当编号有效时,跳出循环
}
}
System.out.println("请输入选手编号:");
int clubId = sc.nextInt();
System.out.println("请输入选手姓名:");
String clubName = sc.next();
System.out.println("请输入选手擅长位置:");
String gameType = sc.next();
// 赋值给到俱乐部
member club_This = new member();
club_This.setMemberId(clubId);
club_This.setMemberName(clubName);
club_This.setProfessional(gameType);
// 将俱乐部对象给到集合中
member.add(club_This);
System.out.print("添加成功!");
}
public static void findMember(ArrayList<member> clubArray){
// 根据id查找俱乐部
Scanner sc = new Scanner(System.in);
System.out.println("输入查找要查找的选手参赛编号:");
int id = sc.nextInt();
// 判断参赛是否存在并查找输出
int flg = -1; //定义一个判断标志,因为数组下标不会为-1.所以将flg初始化为-1
member club_f = new member();
for (int i = 0; i < clubArray.size(); i++) {
club_f = clubArray.get(i);
if(Objects.equals(club_f.getMemberId(), id)){
flg = i;
break;
}
}
if (flg == -1){
System.out.println("该选手未参赛!");
}else{
System.out.println("找到选手!");
System.out.println("选手参赛编号:"+club_f.getMemberId()+"\t姓名:"+club_f.getMemberName()+"\t俱乐部游戏经验类型:"+club_f.getProfessional());
}
}
public static void deleteMember(ArrayList<member> member){
// 删除违规选手参赛资格
Scanner sc = new Scanner(System.in);
System.out.println("输入要删除的选手姓名:");
String name = sc.nextLine();
for (int i = 0; i < member.size(); i++) {
if(member.get(i).getMemberName().equals(name)){
member.remove(i);
break;
}
}
System.out.println("成功删除"+name+"的信息!");
}
public static void showMember(ArrayList<member> member){
//展示所有选手信息
System.out.println("选手编号\t\t姓名\t\t擅长位置");
for (int i = 0; i < member.size(); i++) {
member s = member.get(i);
System.out.println(s.getMemberId()+"\t\t"+s.getMemberName()+"\t\t"+s.getProfessional());
}
}
}
类的设计就不展示了,很简单的一个程序...
感谢观看!