作业四

第6题

 

第9题

class Book{
private String name;
private static int number=0;
private int money;
private static int ceshu;
private String count;
@SuppressWarnings("static-access")
public Book(String name,int number,int money,int ceshu)
{

this.name=name;
this.number=number;
this.money=money;
this.ceshu=ceshu;

this.count=""+number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static int getNumber() {
return number;
}
public static void setNumber(int number) {
Book.number = number;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public static int getCeshu() {
return ceshu;
}
public static void setCeshu(int ceshu) {
Book.ceshu = ceshu;
}
public String information()
{
return "书名为:"+this.name+"\n编号为:"+this.count+"\n价格为:"+this.money+"\n册数为:"+Book.ceshu+"\n";
}
}
public class NinethWork {
public static void main(String[] args) {
Book book[]={
new Book("英雄联盟",001,100,50),new Book("部落冲突",002,200,50),new Book("跑跑卡丁车",003,300,50)
};
int sum=0;
for(int j=0;j<book.length;j++)
{

sum=sum+Book.getCeshu();
System.out.println(book[j].information());
}
System.out.print("总册数为:"+sum);
}

}

posted @ 2016-04-01 14:55  14计科1陈迪  阅读(92)  评论(0编辑  收藏  举报