package org.java.application;
class BookCard {
String Cardnum,name,Idname;//包含账号,持卡人姓名
int borrowsnum,Returnnum,Remain;//已借书数,已还书数,可借书数
//本次借书数//本次还书数。
//方法有借书、还书和查询。
public void borrow(int cash){
if(Remain>=cash){
Remain=Remain-cash;
System.out.println("本次借阅书数"+cash);
System.out.println("可借书数"+Remain);
}
}
public BookCard(String cardnum, String name, String idname, int borrowsnum,int returnnum, int remain) {
Cardnum = cardnum;
this.name = name;
Idname = idname;
this.borrowsnum = borrowsnum;
Returnnum = returnnum;
Remain = remain;
}
public BookCard() {
// TODO Auto-generated constructor stub
}
public void TheReturn(int cash){
Remain=Remain+cash;
System.out.println("本次还书数"+cash);
System.out.println("可借书数"+Remain);
}
public void query(){
System.out.println("可借书数"+Remain);
}
}
public class Task02 {
public static void main(String[] args) { //程序的入口
BookCard wang=new BookCard(); //创建类的对象
wang.borrowsnum=10;
wang.Cardnum="111";
wang.Idname="12345";
wang.name="wangwu";
wang.Remain=5;
wang.Returnnum=2;
wang.borrow(2);
wang.TheReturn(1);
wang.query();
}
}
课堂作业之借书卡
最新推荐文章于 2022-04-21 09:51:12 发布