1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| import java.text.SimpleDateFormat;
public class BankCustomer { private String ID; private String peopleID; private String name; private String phone; private String password; private double balance; public BankCustomer(String peopleID,String name,String phone) {String strDate; SimpleDateFormat myDateFormat =new SimpleDateFormat("yyyyMMddHHmmss"); java.util.Date date0=new java.util.Date(); strDate=myDateFormat.format(date0); ID=strDate; this.peopleID=peopleID; this.name=name; this.phone=phone; this.password="666666"; this.balance=0; } public double getbalance() {return balance;} public String getID() {return ID;} public String getPhone() {return phone;} public String getPelpleID() {return peopleID;} public String getName() {return name;} public void setName(String password,String name) {if(ifPassword(password)) {this.name=name; System.out.println("您的姓名已设置");} else {System.out.println("密码错误");} } public void setPeopleID(String password,String peopleID) {if(ifPassword(password)) {this.peopleID=peopleID; System.out.println("您的身份证号已设置");} else {System.out.println("密码错误");}} public void setPhone(String password,String phone) {if(ifPassword(password)) {this.phone=phone; System.out.println("您的电话已设置");} else {System.out.println("密码错误");} } public boolean ifPassword(String password) {if(this.password==password) return true; else return false; } public void deposit(String password,double money) { if(ifPassword(password)) {balance+=money; System.out.println("您的账户已充值"+balance+"元,您的余额为"+balance);} else {System.out.println("密码错误");} } public void withdraw(String password,double money) {if(ifPassword(password)) {if(balance>money) {balance-=money; System.out.println("您的账户已取出"+balance+"元,您的余额为"+balance);} else {System.out.println("您的余额为不足");}} else {System.out.println("密码错误");} } public void displayCustomer(String password) {if(ifPassword(password)) {System.out.println(" 您的身份证为"+peopleID); System.out.println(" 您的余额为"+balance); System.out.println(" 您的账号为"+ID); System.out.println(" 您的姓名为"+name); System.out.println(" 您的电话为"+phone); } else {System.out.println("密码错误");} } public void changePassWord(String oldPassword,String newPassword1,String newPassword2) {if(ifPassword(oldPassword)) {if( newPassword1== newPassword2) {if(newPassword1.length()>5) {this.password=newPassword1; System.out.println("已修改密码");} else {System.out.println("你输入的密码不到6位,请重新输入");}} else {System.out.println("你输入的两次密码不一样,请重新输入");} } else {System.out.println("密码错误");} } } package text4;
public class Customer { public static void main(String[] args) { BankCustomer myCard=new BankCustomer("430725000000000000","罗琪源","000000000000"); myCard.setName("666666",""); myCard.setName("567891",""); myCard.setPeopleID("666666","430725200112190032"); myCard.setPeopleID("567891","430725200112190032"); myCard.setPhone("666666","18569126258"); myCard.setPhone("567891","18569126258"); myCard.getbalance(); myCard.getID(); myCard.getPhone(); myCard.getPelpleID(); myCard.getName(); myCard.deposit("666666", 5000); myCard.deposit("567891", 5000); myCard.withdraw("666666",10000); myCard.withdraw("567891",10000); myCard.withdraw("567891",5000); myCard.displayCustomer("666666"); myCard.displayCustomer("567891"); myCard.changePassWord("666666", "567891", "567891"); myCard.changePassWord("888888", "567891", "567891"); myCard.changePassWord("567891", "567891", "666666"); myCard.deposit("666666", 5000); myCard.deposit("567891", 5000); myCard.withdraw("666666",10000); myCard.withdraw("567891",10000); myCard.withdraw("567891",5000); myCard.displayCustomer("666666"); myCard.displayCustomer("567891"); myCard.getbalance(); myCard.getID(); myCard.getPhone(); myCard.getPelpleID(); myCard.getName(); myCard.setName("666666",""); myCard.setName("567891",""); myCard.setPeopleID("666666","430725200112190032"); myCard.setPeopleID("567891","430725200112190032"); myCard.setPhone("666666","18569126258"); myCard.setPhone("567891","18569126258"); }
}
|