class Library{
String name; //书名
static int num=0; //编号
float price;
//int sum=0;
static int cbook=0;//册数
static int zcbook=0;//总册数
public Library(String name,float price, int cbook) {
this.name=name;
this.price=price;
this.cbook=cbook;
this.zcbook=zcbook+cbook;
}
public void print() {
System.out.println("书名: " + name + " 编号: "+ num + " 价格: " + price + " 册数: " + cbook);
num=num+cbook;
}
public void z(){
System.out.println("\n" + "总册书为:" + zcbook);
}
}
public class t9 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Library book1 = new Library("Java开发实战经典",100.8f,10);
book1.print();
Library book2 = new Library("Java大学实用教程",60.5f,4);
book2.print();
Library book3 = new Library("名侦探柯南",78.0f, 6);
book3.print();
Library book4 = new Library("JavaEE基础实用教程",36.7f,10);
book4.print();
book4.z();
}
}