网咖系统……简单版

本文介绍了一款简易网咖管理系统的设计与实现,涵盖了客户登录、计费管理、资源监控和基本服务等功能,旨在提高网咖运营效率和服务质量。
import java.util.*;
import java.text.*;
/*
网咖系统
	登录验证
	在线充值
	监控余额(可强制下线)
	多台电脑监控===后期开发
	桌面购物=====后期开发
		支持二维码支付
		支付完成通知网管送货上门
*/
public class PersonageMain
{
	/*
	开通会员
	*/
	public static List<Person> openMember(){
		List<Person> list=new ArrayList<Person>();
		Person person=new Person();
		person.setName("lisi");
		person.setPassword("123456");
		person.setSex("男");
		person.setPhone("15812345678");
		person.setCardNumber("23688195609091234");
		person.setBalance(20.0);
		person.setState(false);
		list.add(person);
	
		for(Person p:list){
			System.out.println("用户:"+p.getName());
			System.out.println("密码:"+p.getPassword());
			System.out.println("性别:"+p.getSex());
			System.out.println("手机号码:"+p.getPhone());
			System.out.println("身份证号码:"+p.getCardNumber());
			System.out.println("账户余额:"+p.getBalance());
			if(person.getState()==false){
				System.out.println("用户状态:未上机");
			}else{
				System.out.println("用户状态:上线中");
			}
			//System.out.println("用户状态:"+p.getState());
		}
		return list;
	}
	/*
	登录开始游戏
	*/
	public static void begin(List<Person> list){
		//List<Person> list=openMember();
		//consumption(list);
		Scanner scanner=new Scanner(System.in);
		for(Person person:list){
			int a=0;
			int b=0;
			for(int i =0;i<3;i++){
				System.out.print("账户:");
				String name=scanner.next();
				if(person.getName().equals(name)){
					System.out.println("账号输入正确");
					break;
				}else{
					a++;
					System.out.println("账号输入有误"+a+"次"+",请重新输入");
					}
				}
			for(int i =0;i<3;i++){
				System.out.print("密码:");
				String password=scanner.next();
				if(person.getPassword().equals(password)){
					System.out.println("密码输入正确");
					break;
				}else{
					b++;
					System.out.println("密码输入有误"+b+"次"+",请重新输入");
				}
			}
			person.setState(true);
			if(person.getBalance()<=0){
				System.out.println("您的账户余额不足,请充值!");
				//充值方法
				topUp(list);
			}
			
			//上线时间
			timerStart(list);
		}
	}
	
	//充值方法
	public static double topUp(List<Person> list){
		double d=0.0;
		for(Person person:list){
		Scanner scanner =new Scanner(System.in);
		if(person.getState()==false){
			System.out.print("请输入充值用户:");
			String name=scanner.next();
			if(name.equals(person.getName())){
				double f1=0.0;
				double money1=0.0;
				while(true){
					System.out.print("是否要充值y/n:");
					String str=scanner.next();
					if(str.equals("y")){
						System.out.print("请输入充值金额:");
						money1=scanner.nextDouble();
						//充值金额加上原有剩余金额
						f1=person.getBalance()+money1;
						//总和提交给余额存储
						person.setBalance(f1);
						d+=person.getBalance();
						System.out.println("账户余额:"+person.getBalance());
					}else if(str.equals("n")){
						break;
					}
					}
			}else{
				System.out.println("账号错误!");
			}
		}else {
		double f1=0.0;
		double money1=0.0;
		while(true){
		System.out.print("是否要充值y/n:");
		String str=scanner.next();
		if(str.equals("y")){
			System.out.print("请输入充值金额:");
			money1=scanner.nextDouble();
			//充值金额加上原有剩余金额
			f1=person.getBalance()+money1;
			//总和提交给余额存储
			person.setBalance(f1);
			d+=person.getBalance();
			System.out.println("账户余额:"+person.getBalance());
		}else if(str.equals("n")){
			break;
		}
		
		}
		}
		}
		return d;
		
	
	}
	//上线时间 
	public static void timerStart(List<Person> list){
		Date d1=;
		for(Person person:list){
			if(person.getBalance()>0){
				//上线时间
				 d1 =new Date();
				//监控的余额大于账户余额,则继续监控
				MonitoringThread mt=new MonitoringThread(d1,list);
				mt.start();
				if(monitoring(d1,list)){//监控余额为true
					if(person.getState()){//登录成功状态true
						System.out.println("用户状态:上线中");
						DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
						try
						{
							String d12 = df.format(d1);
							System.out.println("上线时间:"+d12);
						}
						catch (Exception e)
						{
							e.printStackTrace();
						}
					}
					//充值
					//topUp(list);
					//下线
					timerFinish(d1,list);
					break;
					}
			}else{
				//充值方法
				System.out.println("余额不足请充值");
				topUp(list);
			}
			
		}
		//return d1;
	}
	//下线时间
	public static  void timerFinish(Date d1,List<Person> list){
		///Date d1=timerStart(list);// 上线时间
		Scanner scanner =new Scanner(System.in);
		for(Person person:list){
			if(monitoring(d1,list)!=true){//监控费用为false
				//强制下线
				Date d2=new Date();
				person.setState(false);
				System.out.println("您已强制下线");
				//计算上机时间
				startFinishTimer(d1,d2,list);
				break;
			}
				//正常下线
				System.out.print("是否要下线y/n:");
				String st=scanner.next();
				if(st.equals("y")){
					Date d2=new Date();
					person.setState(false);
					System.out.println("您已下线");
				//计算上机时间
					startFinishTimer(d1,d2,list);
					break;
				}else if(st.equals("n")){
					System.out.println("继续上线");
			}
			
		}
	}
		
	
	//上线 下线时间时间计算
	public static  void startFinishTimer(Date d1,Date d2,List<Person> list){
				String timeT=;
							DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
							try
							{
								//d2 = df1.format(new Date());
								//Date d3=df.parse(d1);
								//Date d4=df1.parse(d2);
								long diff = d2.getTime() - d1.getTime();//这样得到的差值是微秒级别
								System.out.println("下线时间:"+df1.format(d2));
								long days = diff / (1000 * 60 * 60 * 24);
								long hours = (diff-days*(1000 * 60 * 60 * 24))/(1000* 60 * 60);
								long minutes = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60))/(1000* 60);
								long ss = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60)-minutes*(1000*60))/(1000);
								System.out.println("本次上机时间为:"+days+"天"+hours+"小时"+minutes+"分"+ss+"秒");
								timeT=days+"-"+hours+"-"+minutes;
								//System.out.println("上机总时长"+timeT);
							}catch (Exception e){}
			//计费
			consumption(timeT,list);
			
		}
		
		
		
		
		
		
	
	//上线 下线 时间产生费用
	public static void consumption(String timeT,List<Person> list){
		try{//空指针异常
	 //进行分割
	  String d[]=timeT.split("-");
	 //对于取出
	  String	days=d[0];
	  String  hours=d[1];
	  String minutes=d[2];
	  String timeK=days+"天"+hours+"时"+minutes+"分钟";
	
	 //字符串转换数值
	  int da=Integer.parseInt(days);
	  int h=Integer.parseInt(hours);
	  int m=Integer.parseInt(minutes);
	/*
	int da=1;
	int h=2;
	int m=30;
	*/
	 /*1.账户余额      
	 2.计费标准 
	 分钟:0.2元
	 小时:12元
	 3.设置余额低于5分钟提醒充值
	 */
	double fei_d=100;//天收费
	double fei_h=5.0;//时收费
	double fei_m=10;//分收费
	System.out.println("上机总时间:"+timeK);

	for(Person p:list){
		if(da>=1){//上机时间大于1天
			double newFei=da*fei_d;
			//System.out.println("本次消费"+newFei+"元");
			if(p.getBalance()>=newFei){//余额大于消费金额
				double sy=p.getBalance()-newFei;
				p.setBalance(sy);
				System.out.println(da+"天"+"*"+fei_d+"元/天\n"+"消费:"+newFei+"元");
			}else{//小于请充值
				System.out.println("余额不足");
				topUp(list);
			}
		}

		if(h>=1){//上机时间大于1小时
			double newFei=h*fei_h;
			//System.out.println("本次消费"+newFei+"元");
			if(p.getBalance()>=newFei){//余额大于消费金额
				double sy=p.getBalance()-newFei;
				p.setBalance(sy);
				System.out.println(h+"时"+"*"+fei_h+"元/时\n"+"消费:"+newFei+"元");
			}else{//小于请充值
				System.out.println("余额不足");
				topUp(list);
			}
		}

		if(m>=1){//上机时间大于1分钟
			double newFei=m*fei_m;
			//System.out.println("本次消费"+newFei+"元");
			if(p.getBalance()>=newFei){//余额大于消费金额
				double sy=p.getBalance()-newFei;
				p.setBalance(sy);
				System.out.println(m+"分钟"+"*"+fei_m+"元/分钟\n"+"消费:"+newFei+"元");
			}else{//小于请充值
				System.out.println("余额不足");
				topUp(list);
			}
		}
		System.out.println("下机剩余金额:"+p.getBalance());
	}
	
	}catch(NullPointerException e){
		e.printStackTrace();
	}
	}

	//监控  monitoring
	public static boolean monitoring(Date d,List<Person> list){
	/*
	监控目的
		账户余额是否大于上线时间
		条件
			账户余额
			在线时间
	*/
		
		DateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String timeT=;
		try
		{
			//Date d3=df.parse(d);//上线时间  8-8
			String d2 = df.format(new Date());//当前时间   9-10
			Date d4=df.parse(d2);
			long diff = d4.getTime() - d.getTime();//这样得到的差值是微秒级别
		
			long days = diff / (1000 * 60 * 60 * 24);
			long hours = (diff-days*(1000 * 60 * 60 * 24))/(1000* 60 * 60);
			long minutes = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60))/(1000* 60);
			long ss = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60)-minutes*(1000*60))/(1000);
			System.out.println("本次上机时间为:"+days+"天"+hours+"小时"+minutes+"分"+ss+"秒");
			timeT=days+"-"+hours+"-"+minutes;
			//System.out.println("上机总时长"+timeT);
		}catch (Exception e){
		}
		//进行分割
		String str[]=timeT.split("-");
		//对于取出
		String	days=str[0];
		String  hours=str[1];
		String minutes=str[2];
		String timeK=days+"天"+hours+"时"+minutes+"分钟";
		/*
		int da=1;
		int h=2;
		int m=33;
		*/
		//字符串转换数值
		int da=Integer.parseInt(days);
		int h=Integer.parseInt(hours);
		int m=Integer.parseInt(minutes);
		
		double fei_d=100;//天收费
		double fei_h=5.0;//时收费
		double fei_m=10;//分收费
		System.out.println("上机总时间:"+timeK);
		
		
		double new_sum=0.0;//每次监控累加
		double sum=0.0;		//共计消费
		for(Person p:list){
			if(sum<=p.getBalance()){
			
				if(da>=1){//上机时间大于1天
					double newFei=da*fei_d;
					//System.out.println("本次消费"+newFei+"元");
					if(p.getBalance()>=newFei){//余额大于消费金额
						//double sy=p.getBalance()-newFei;
						//p.setBalance(sy);
						new_sum+=newFei;
						System.out.println(da+"天"+"*"+fei_d+"元/天\n"+"消费:"+newFei+"元");
					}else{//小于请充值
						System.out.println("余额不足");
						topUp(list);
					}
				}

				if(h>=1){//上机时间大于1小时
					double newFei=h*fei_h;
					//System.out.println("本次消费"+newFei+"元");
					if(p.getBalance()>=newFei){//余额大于消费金额
						//double sy=p.getBalance()-newFei;
						//p.setBalance(sy);
						new_sum+=newFei;
						System.out.println(h+"时"+"*"+fei_h+"元/时\n"+"消费:"+newFei+"元");
					}else{//小于请充值
						System.out.println("余额不足");
						topUp(list);
					}
				}

				if(m>=1){//上机时间大于1分钟
					double newFei=m*fei_m;
					//System.out.println("本次消费"+newFei+"元");
					if(p.getBalance()>=newFei){//余额大于消费金额
						//double sy=p.getBalance()-newFei;
						//p.setBalance(sy);
						new_sum+=newFei;
						System.out.println(m+"分钟"+"*"+fei_m+"元/分钟\n"+"消费:"+newFei+"元");
					}else{//小于请充值
						System.out.println("余额不足");
						topUp(list);
					}
				}
			}	
				
				
			sum=new_sum-sum;//用本次消费减去上次消费得到一共消费金额

			System.out.println("监控消费"+sum);
			System.out.println("余额"+p.getBalance());
			
		if(sum>=p.getBalance()){
			System.out.println("监控。。。本次消费余额不足");
			return false;
		}
		
			}
		return true;
	
	}
	
	
	//欢迎页面
	public static void welcome(){
		List<Person> list=openMember();
		Scanner scanner =new Scanner(System.in);
		//System.out.print("是否继续 y/n:");
		String str=;
		do{
			System.out.println("<=============>");
			System.out.println("欢迎进入网咖系统");
			System.out.println("<=============>");
			System.out.print("1.登录\n2.充值\n0.退出\n请输入编号:");
			int i=scanner.nextInt();
			switch(i){
				case 1:
					begin(list);
					break;
					
				case 2:
					topUp(list);
					break;
					
				case 0: 
					break;
			}
		System.out.print("是否继续 y/n:");
		 str=scanner.next();
		}while(str.equals("y"));
		if(str.equals("n")){
			System.out.println("退出");
		}
	}
	
	
	public static void main(String[] args)
	{
		//openMember();
		//monitoring();
		//begin();
		welcome();
	}
}
class MonitoringThread extends Thread
{
	PersonageMain p=new PersonageMain();
	Date date;
	List<Person> list;
	
	public MonitoringThread(Date date,List<Person> list){
		this.date=date;
		this.list=list;
	}
	@Override
	public void run()
	{
		try{
			while(true){
				if(p.monitoring(date,list)){
					//p.timerFinish(date,list);//如果为true正常下线
				
				}else{
					System.out.println("监控。。。账户余额不足");
					p.timerFinish(date,list);//如果为false强制下线
					break;
				}

				try{
					Thread.sleep(63000);//分钟
				}catch(Exception e){}
			}
		}catch(NullPointerException e){
			e.printStackTrace();
		}
		
		}
		
	
}
	

class Person{
	String name="";//姓名
	String password="";//密码
	String sex="";//性别
	String cardNumber="";//身份证号码
	String phone="";//手机号码
	double balance=0.0;//余额
	boolean state =false;//状态
	
	public String getName(){
		return this.name;
	}
	public void setName(String name){
		this.name=name;
	}
	public String getPassword(){
		return this.password;
	}
	public void setPassword(String password){
		this.password=password;
	}
	public String getSex(){
		return this.sex;
	}
	public void setSex(String sex){
		this.sex=sex;
	}
	public String getCardNumber(){
		return this.cardNumber;
	}
	public void setCardNumber(String cardNumber){
		this.cardNumber=cardNumber;
	}
	public String getPhone(){
		return this.phone;
	}
	public void setPhone(String phone){
		this.phone=phone;
	}
	public double getBalance(){
		return this.balance;
	}
	public void setBalance(double balance){
		this.balance=balance;
	}
	public boolean getState(){
		return this.state;
	}
	public void setState(boolean state){
		this.state=state;
	}
}
class StateText extends Thread
{
	@Override
	public void run()
	{
		// TODO: Implement this method
		super.run();
		for(int i=0;i<60;i++){
			System.out.println(i);
			/*	
			 Thread.interrupted();//判断是否中断,并清除中断状态
			 Thread.currentThread().isInterrupted();//判断是否中断
			 */
			try{
				this.sleep(1000);
			}catch(Exception e){

			}
		}

	}
	
	/*
	 1.启用线程监控金额是否小于0
	 2.小于0则弹出窗口提示
	 
	
*/
}
	

一、 内容概要 本资源提供了一个完整的“金属板材压弯成型”非线性仿真案例,基于ABAQUS/Explicit或Standard求解器完成。案例精确模拟了模具(凸模、凹模)与金属板材之间的接触、压合过程,直至板材发生塑性弯曲成型。 模型特点:包含完整的模具-工件装配体,定义了刚体约束、通用接触(或面面接触)及摩擦系数。 材料定义:金属板材采用弹塑性材料模型,定义了完整的屈服强度、塑性应变等真实应力-应变数据。 关键结果:提供了成型过程中的板材应力(Mises应力)、塑性应变(PE)、厚度变化​ 云图,以及模具受力(接触力)曲线,完整再现了压弯工艺的力学状态。 二、 适用人群 CAE工程师/工艺工程师:从事钣金冲压、模具设计、金属成型工艺分析与优化的专业人员。 高校师生:学习ABAQUS非线性分析、金属塑性成形理论,或从事相关课题研究的硕士/博士生。 结构设计工程师:需要评估钣金件可制造性(DFM)或预测成型回弹的设计人员。 三、 使用场景及目标 学习目标: 掌握在ABAQUS中设置金属塑性成形仿真的全流程,包括材料定义、复杂接触设置、边界条件与载荷步。 学习如何调试和分析大变形、非线性接触问题的收敛性技巧。 理解如何通过仿真预测成型缺陷(如减薄、破裂、回弹),并与理论或实验进行对比验证。 应用价值:本案例的建模方法与分析思路可直接应用于汽车覆盖件、电器外壳、结构件等钣金产品的冲压工艺开发与模具设计优化,减少试模成本。 四、 其他说明 资源包内包含参数化的INP文件、CAE模型文件、材料数据参考及一份简要的操作要点说明文档。INP文件便于用户直接修改关键参数(如压边力、摩擦系数、行程)进行自主研究。 建议使用ABAQUS 2022或更高本打开。显式动力学分析(如用Explicit)对计算资源有一定要求。 本案例为教学与工程参考目的提供,用户可基于此框架进行拓展,应用于V型弯曲
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值