创建对象时总说找不到符号,请帮帮解决下~~~
public class Card{int id;
int balance;
Card(int id,int balance){
this.id=id;
this.balance=balance;
}
void withdraw(int amount){
balance-=amount;
}
void deposit(int amount){
balance+=amount;
}
void print(){
System.out.printf("Card id:%10d \nBalance:$%8.2d",id,balance);
}
}
class CardTest{
public static void main(String args[]){
Card a=new Card(1,500);
Card b=open(2);
transfer(a,b,120);
a.print();
b.print();
}
static Card open(int id){
return new Card(id,0);
}
static void transfer(Card from,Card to,int amount){
from.withdraw(amount);
to.deposit(amount);
Card temp=from;
from=to;
to=temp;
}
}
[ 本帖最后由 long8855381 于 2014-4-12 18:42 编辑 ]