单机版(新手教学)理发店管理系统

主类

package com.jnd.text;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class aaaa {
	final static List myl = new ArrayList();
	final static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) throws ParseException {
		/*
		 * 显示“欢迎使用理发店管理系统,请选择功能: 1-新增会员卡, 2-打印显示所有会员卡信息, 3-会员卡充值, 4-排序(按余额由高到低),5-退出”
		 */
		while (true) {
			int i=0;
			System.out.println("欢迎使用理发店管理系统,请选择功能: 1-新增会员卡, 2-打印显示所有会员卡信息, 3-会员卡充值, 4-排序(按余额由高到低),5-退出");
			i=sc.nextInt();
			if(i==1){
				adduser();
				continue;
			}
			if(i==2){
				showuser();
				continue;
			}
			if(i==3){
				addmoney();
				continue;
			}
			if(i==4){
				ordermoney();
				continue;
			}
			if(i==5){
				break;
			}
		}
	}
	//新增会员卡
	public static void adduser(){
		int uid =myl.size()+1;
		String uname="";
		while(uname==""){
			System.out.println("请输入"+uid+"号用户的名称");
			uname = sc.next();
		};
		
		float money =0;
		System.out.println("请输入用户原始金额");
		money = sc.nextFloat();
		
		User myu=new User();
		myu.setUid(uid);
		myu.setUname(uname);
		myu.setMoney(money);
		myl.add(myu);
	}
	//打印所有会员卡信息
	public static void showuser(){
		for (int i = 0; i < myl.size(); i++) {
			new User(myl.get(i).getUid(), myl.get(i).getUname(), myl.get(i).getMoney());
		}
	}
	//根据卡号充值
	public static void addmoney(){
		System.out.println("请输入需要充值的用户的id");
		int uid =0;
		while (uid==0) {
			uid=sc.nextInt();
			float money =0;
			System.out.println("请输入需要充值的金额");
			money = sc.nextFloat();
			for (int i = 0; i < myl.size(); i++) {
				if (myl.get(i).getUid()==uid) {
					myl.get(i).setMoney(myl.get(i).getMoney()+money);
				}
			}
		}
	}
	//根据余额排序从大到小
	public static void ordermoney(){
		User myu=new User();
		for(int i=0;i

user类

package com.jnd.text;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

public class User {
	
	private int uid;
	private String uname;
	private float money;
	
	//封装属性
	public int getUid() {
		return uid;
	}
	public void setUid(int uid) {
		this.uid = uid;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public float getMoney() {
		return money;
	}
	public void setMoney(float money) {
		this.money = money;
	}
	
	//构造函数
	
	public User() {
		// TODO Auto-generated constructor stub
	}
	
	public User(int uid,String uname,float money) {
		// TODO Auto-generated constructor stub
		System.out.println("id:"+uid+",名字:"+uname+",余额:"+money);
	}
	
}

你可能感兴趣的:(JAVA,单机)