书卡类给你写出来了,主类自己写。你可以在这个的基础是添加一个根据用户选择去调用不同的方法,在主类里面去判断用户的输入,然后调用不同的方法。
public class BookCard {
private String account;
private String name;
private int borrowed;
private int available;
public BookCard() {
}
public BookCard(String account, String name, int available) {
this.account = account;
this.name = name;
this.available = available;
}
public int borrow(int sum){
System.out.println("本次借书:"+sum);
borrowed += sum;
System.out.println("总借书:"+borrowed);
available -= sum;
System.out.println("可借书:"+available);
return borrowed;
}
public int theReturn(int sum){
System.out.println("本次还书:"+sum);
borrowed -= sum;
System.out.println("总借书:"+borrowed);
available += sum;
System.out.println("可借书:"+available);
return borrowed;
}
public void query(){
System.out.println("总借书:"+borrowed);
System.out.println("可借书:"+available);
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBorrowed() {
return borrowed;
}
public void setBorrowed(int borrowed) {
this.borrowed = borrowed;
}
public int getAvailable() {
return available;
}
public void setAvailable(int available) {
this.available = available;
}
}