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