?? user.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 + -