⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user.java

📁 一个基于局域网的c/s模式网上购物系统,功能比较全面.数据库为Access.
💻 JAVA
字号:
import java.io.*;

//////用户类///////
class User
{
	private int Id;
	private int account;
	private String userName;
	private String password;
	
	
	User(int Id,String userName,String password,int account)
	{
		this.Id = Id;
		this.userName = userName;
		this.password = password;
		this.account = account;
	}
	
	public int getId()
	{
		return Id;
	}
	
	public int getAccount()
	{
		return account;
	}
	
	public String getUserName()
	{
		return userName;
	}
	
	public String getPassword()
	{
		return password;
	}

	public void setUserName(String name)
	{
		this.userName = name;
	}
	
	public void setPassword(String pswd)
	{
		this.password = pswd;
	}
	
	public void setAccount(int acnt)
	{
		this.account = acnt;
	}
	
	public double checkBalance(BufferedReader in,PrintWriter out)
	{
		try
		{
			out.println("CHECK");
			out.println(this.account);
			
			double balance = Double.parseDouble(in.readLine());
			return balance;
		}catch(Exception e){System.out.println(e);return -1;}

	}
	
		
	public void withdraw(double amount,BufferedReader in,PrintWriter out)
    {
    	try
    	{
   		 	out.println("WITHDRAW");
    		out.println(this.account);
   		 	out.println(amount);
   		 	
   		 	String result = in.readLine();
    	    	
    		if(result.equals("SUCCESS")) 
    		{
    			System.out.println("You have withdrawed "+amount);
    		}

   		 	else
   		 	{
   		 		System.out.println("ERROR!");
   		 	}

    	}
    	catch(Exception e){}
    }
    
    public void deposit(double amount,BufferedReader in,PrintWriter out)
    {
    	try
    	{
	 		out.println("DEPOSIT");
   			out.println(this.account);
	 		out.println(amount);
   		 	
	 		String result = in.readLine();
 	    	
  			if(result.equals("SUCCESS")) 
   			{
   				System.out.println("You have deposited "+amount);
   			}
    		
   		 	else
   		 	{
   		 		System.out.println(result+"ERROR!");
   		 	}

    	}
    	catch(Exception e){}
    }
	
}

//////顾客类///////
class Customer extends User
{
	private boolean merchant;
	
	Customer(int Id,String userName,String password,int account,boolean m)
	{
		super(Id,userName,password,account);
		merchant = m;
	}
	
	public boolean isMerchant()
	{
		return merchant;
	}
	
	public void setMerchant()
	{
		merchant = true;
	}
}

//////店主类///////
class Merchant extends User
{
	private String shopName;
	private String shopType;
	private String shopInfo;
	
	Merchant(int Id,String userName,String password,String shopName,String shopType,String shopInfo,int account)
	{
		super(Id,userName,password,account);
		this.shopName = shopName;
		this.shopType = shopType;
		this.shopInfo = shopInfo;
	}
	
	public String getShopName()
	{
		return shopName;
	}
	
	public String getShopType()
	{
		return shopType;
	}
	
	public String getShopInfo()
	{
		return shopInfo;
	}
	
	public void setShopName(String str)
	{
		shopName = str;
	}
	
	public void setShopType(String str)
	{
		shopType = str;
	}
	
	public void setShopInfo(String str)
	{
		shopInfo = str;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -