该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
代码:发不了压缩文件。。。因为没有头衔。。。。
package javaapplication78;
public class JavaApplication78 {
public static void main(String[] args) {
People p1=new People("chiris","M","bEIJING");
BankAccount b = new BankAccount("ChrisAccount", 1,1000.0,p1);
boolean withdrawWorked = b.withdraw(1000);
System.out.println(withdrawWorked);
System.out.println(b.display());
b.deposit(2000);
System.out.println(b.display());}}
第二个class:
package javaapplication78;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Scanner;
public class DataInput {
static Scanner kb = new Scanner(System.in);
public void dataEntry() {
ArrayList listOfAccounts = null;
System.out.println("Enter the accountNumber:");
int n = kb.nextInt();
System.out.print("Enter the pinnumber:");
int g = kb.nextInt();
Iteratorit=listOfAccounts.iterator();
while(it.hasNext()){
BankAccount an=it.next();
if(an.accountnumber()==n){
if(an.pinnumber()==g){
System.out.println("Welcome");
}else{System.out.println("WRONG CODE");}}else{System.out.println("WRONG NUMBER");
}}}}
第3个class:
package javaapplication78;
import java.util.ArrayList;
public class People {
private String name;
private String gender;
private String address;private int idNumber;
public static int lastId = 0;
public static ArrayList listOfPeople = new ArrayList();
public People(String name,String gender,String address){
this.name=name;
this.gender=gender;
this.address=address;
lastId++;
this.idNumber = lastId;
listOfPeople.add(this);
}
public String getName() {
return name;
}}
第4个class:
package javaapplication78;
import java.util.ArrayList;
import java.util.Scanner;
public class BankAccount {
// object attributes
private String accountName;
private double accountBalance;
private int accountNumber;
private int pinNumber;
private People accountOwner;
// class attributes
public static ArrayList listOfAccounts;
private static int lastAccountNumber=0000000;
public BankAccount(String name ,int pinnumber, double balance,People owner){
this.accountName=name;
this.pinNumber=pinnumber;
this.accountBalance=balance;
this.accountOwner = owner;
lastAccountNumber++;
this.accountNumber = lastAccountNumber;
listOfAccounts.add(this); }
public int accountnumber(){
return accountNumber;}
public int pinnumber(){
return pinNumber;}
public String accountDetails() {
String details = "";
details = details + "Account name: " + this.accountName + "\n";
details = details + "Account owner: " + this.accountOwner.getName() + "\n";
details= details + "Account number: " + this.accountNumber + "\n";
details=details+"Account pin number"+this.pinNumber+"\n";
details = details + "Account balance: " + this.accountBalance + "\n";
return details;
}
public boolean withdraw(double m){ boolean ok = false;
if (this.accountBalance >= m) {
this.accountBalance = this.accountBalance - m;
ok = true; }
return ok; }
public void deposit(double m) { this.accountBalance = this.accountBalance + m;
}
public String display(){
String display="";
display=display+"accountbalance:"+accountBalance;
return display;
}}
求大神啊啊啊啊啊啊啊。。