Java作业,在线等答案~

建立银行账户类:Account,里面包含有(id,name,bank,balance)属性,其中bank为static类型的类属性。要求生成十个Account对象,并输出... 建立银行账户类:Account,里面包含有(id,name,bank,balance)属性,其中bank为static类型的类属性。
要求生成十个Account对象,并输出这10个对象的属性信息~
拜托喽,求最快速度,两小时内可给分,只要符合要求,是不是自己写的都可以~
快了的话可以加分~
展开
 我来答
miniapp16e43ddfde28
2011-03-31 · TA获得超过639个赞
知道小有建树答主
回答量:737
采纳率:0%
帮助的人:526万
展开全部
public class Account {
private Long id;
private String name;
private float blance;
private static Bank bank;

//标准的toString方法
public String toString(){
return "id:"+id+"\n客户:"+name+id+"\nBank:"+bank.getBankName();
}

/**
* @param args
* 主方法
*/
public static void main(String[] args) {
Account account[]=new Account[10];
Bank bank=new Bank();
bank.setBankName("中国银行");
for(int i=0;i<10;i++){
account[i]=new Account();
account[i].setBlance(1000*i);
account[i].setId(6550000000004844l+i);
Account.setBank(bank);
account[i].setName("客户"+i);
}
for(int i=0;i<10;i++){
System.out.println(account[i].toString());
}
}

//以下是setter和getter
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getBlance() {
return blance;
}
public void setBlance(float blance) {
this.blance = blance;
}
public static Bank getBank() {
return bank;
}
public static void setBank(Bank bank) {
Account.bank = bank;
}
}
//银行类
class Bank{
private String bankName;
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
}

将以上代码存成Account.java 编译运行就可以了
yd135123
2011-03-31
知道答主
回答量:11
采纳率:0%
帮助的人:9.2万
展开全部
这么简单的也来问哦。。。看下书就会了。。哈哈
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友0583ac2ea
2011-03-31 · TA获得超过957个赞
知道小有建树答主
回答量:167
采纳率:0%
帮助的人:217万
展开全部
package bb;

import java.util.ArrayList;
import java.util.List;

public class Account {

//id,name,bank,balance
private String id;
private String name;
private double balance;

private static String bank;

public Account(){ }

public Account(String id, String name, double balance) {
super();
this.id = id;
this.name = name;
this.balance = balance;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public double getBalance() {
return balance;
}

public void setBalance(double balance) {
this.balance = balance;
}

public static String getBank() {
return bank;
}

public static void setBank(String bank) {
Account.bank = bank;
}

@Override
public String toString() {
return "Bank:" + Account.bank +
" id:" + this.id +
" name:" + this.name +
" balance:" + this.balance;
}

/**
* @param args
*/
public static void main(String[] args) {
setBank("China Bank");
List<Account> accounts = new ArrayList<Account>();
for(int i = 0; i < 10; i++ ){
Account acc = new Account();
acc.setBalance(i*100);
acc.setId("00" + i );
acc.setName("name" + i);
accounts.add(acc);
}

for(Account account : accounts){
System.out.println(account);
}

}

}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
flyingFish211
2011-03-31 · TA获得超过2.1万个赞
知道大有可为答主
回答量:1.5万
采纳率:50%
帮助的人:1.1亿
展开全部
public class Account {

private int id;
private String name;
private static String bank = "ICBC";
private double balance;

public Account(int id, String name){
this.id = id;
this.name = name;
}

public static void main(String[] args) {
Account acct1 = new Account(1, "Zhang san");
acct1.setBalance(111);
Account acct2 = new Account(22, "Li Si");
acct2.setBalance(222);
Account acct3 = new Account(3, "Wang Wu");
acct3.setBalance(33333);
Account acct4 = new Account(4, "Ma Liu");
acct4.setBalance(55555);
Account acct5 = new Account(5, "Wang Ba");
acct5.setBalance(222343);
Account acct6 = new Account(6, "AAAA");
Account acct7 = new Account(77, "BBB");
Account acct8 = new Account(35, "Bank name 3");
Account acct9 = new Account(88, "Lu Ren JIa");
Account acct10 = new Account(125, "Lu ren yi");

acct1.printAcctInfo();
acct2.printAcctInfo();
acct3.printAcctInfo();
acct4.printAcctInfo();
acct5.printAcctInfo();
acct6.printAcctInfo();
acct7.printAcctInfo();
acct8.printAcctInfo();
acct9.printAcctInfo();
acct10.printAcctInfo();
}

public void printAcctInfo(){
System.out.println("Account's Id: " + id);
System.out.println("Account's name: " + name);
System.out.println("Account's bank: " + bank);
System.out.println("Account's balance: " + balance);
System.out.println();
}

public void setBalance(double balance) {
this.balance = balance;
}
}
---------------测试结果
Account's Id: 1
Account's name: Zhang san
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 22
Account's name: Li Si
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 3
Account's name: Wang Wu
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 4
Account's name: Ma Liu
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 5
Account's name: Wang Ba
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 6
Account's name: AAAA
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 77
Account's name: BBB
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 35
Account's name: Bank name 3
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 88
Account's name: Lu Ren JIa
Account's bank: ICBC
Account's balance: 0.0

Account's Id: 125
Account's name: Lu ren yi
Account's bank: ICBC
Account's balance: 0.0
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
市懿93
2011-03-31 · TA获得超过196个赞
知道答主
回答量:85
采纳率:0%
帮助的人:84.8万
展开全部
public class Account {
private Long id;
private String name;
private float blance;
private static Bank bank;

//标准的toString方法
public String toString(){
return "id:"+id+"\n客户:"+name+id+"\nBank:"+bank.getBankName();
}

/**
* @param args
* 主方法
*/
public static void main(String[] args) {
Account account[]=new Account[10];
Bank bank=new Bank();
bank.setBankName("中国银行");
for(int i=0;i<10;i++){
account[i]=new Account();
account[i].setBlance(1000*i);
account[i].setId(6550000000004844l+i);
Account.setBank(bank);
account[i].setName("客户"+i);
}
for(int i=0;i<10;i++){
System.out.println(account[i].toString());
}
}

//以下是setter和getter
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getBlance() {
return blance;
}
public void setBlance(float blance) {
this.blance = blance;
}
public static Bank getBank() {
return bank;
}
public static void setBank(Bank bank) {
Account.bank = bank;
}
}
//银行类
class Bank{
private String bankName;
public String getBankName() {
return bankName;
}
public void setBankName(String bankName) {
this.bankName = bankName;
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
优若光W
2011-03-31 · TA获得超过199个赞
知道小有建树答主
回答量:140
采纳率:0%
帮助的人:166万
展开全部
趁楼主还没入行,强烈建议楼主改行,兴趣不在这
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(4)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式