
用Java编写一个图书类程序:1.属性:图书编号,图书名称,出版社,库存量。2.构造方法:至少两个
用Java编写一个图书类程序:1.属性:图书编号,图书名称,出版社,库存量。2.构造方法:至少两个。3.方法:输图书信息,输出图书信息,修改库存量...
用Java编写一个图书类程序:1.属性:图书编号,图书名称,出版社,库存量。2.构造方法:至少两个。3.方法:输图书信息,输出图书信息,修改库存量
展开
1个回答
展开全部
import java.lang.*;
public class Test{
public static void main(String[] args){
Book book = new Book("111", "name", "publisher", 1);
book.PrintBookMessage();
System.out.println("Book NO:" + book.GetBookNumber() + "\n" + "Book name:" + book.GetBookName() +
"\n" + "Publisher name:" + book.GetPublisherName() + "\n" + "Store:" + book.GetStore());
}
}
class Book{
private static String strBookNumber;
private static String strBookName;
private static String strPublisherName;
private static int nStore;
public Book(){
strBookNumber = null;
strBookName = null;
strPublisherName = null;
nStore = 0;
}
public Book(String strBookNumber, String strBookName, String strPublisherName, int nStore){
this.strBookNumber = strBookNumber;
this.strBookName = strBookName;
this.strPublisherName = strPublisherName;
this.nStore = nStore;
}
public void SetBookName(String strBookName){
this.strBookName = strBookName;
}
public String GetBookName(){
return this.strBookName;
}
public void SetBookNumber(String strBookName){
this.strBookNumber = strBookNumber;
}
public String GetBookNumber(){
return this.strBookNumber;
}
public void SetPublisherName(String strPublisherName){
this.strPublisherName = strPublisherName;
}
public String GetPublisherName(){
return this.strPublisherName;
}
public int GetStore(){
return this.nStore;
}
public void SetStore(int nStore){
this.nStore = nStore;
}
public void PrintBookMessage(){
System.out.println("Book NO:" + this.strBookNumber + "\n" + "Book name:" + this.strBookName +
"\n" + "Publisher name:" + this.strPublisherName + "\n" + "Store:" + this.nStore);
}
}
能用的,采纳了吧~~~
public class Test{
public static void main(String[] args){
Book book = new Book("111", "name", "publisher", 1);
book.PrintBookMessage();
System.out.println("Book NO:" + book.GetBookNumber() + "\n" + "Book name:" + book.GetBookName() +
"\n" + "Publisher name:" + book.GetPublisherName() + "\n" + "Store:" + book.GetStore());
}
}
class Book{
private static String strBookNumber;
private static String strBookName;
private static String strPublisherName;
private static int nStore;
public Book(){
strBookNumber = null;
strBookName = null;
strPublisherName = null;
nStore = 0;
}
public Book(String strBookNumber, String strBookName, String strPublisherName, int nStore){
this.strBookNumber = strBookNumber;
this.strBookName = strBookName;
this.strPublisherName = strPublisherName;
this.nStore = nStore;
}
public void SetBookName(String strBookName){
this.strBookName = strBookName;
}
public String GetBookName(){
return this.strBookName;
}
public void SetBookNumber(String strBookName){
this.strBookNumber = strBookNumber;
}
public String GetBookNumber(){
return this.strBookNumber;
}
public void SetPublisherName(String strPublisherName){
this.strPublisherName = strPublisherName;
}
public String GetPublisherName(){
return this.strPublisherName;
}
public int GetStore(){
return this.nStore;
}
public void SetStore(int nStore){
this.nStore = nStore;
}
public void PrintBookMessage(){
System.out.println("Book NO:" + this.strBookNumber + "\n" + "Book name:" + this.strBookName +
"\n" + "Publisher name:" + this.strPublisherName + "\n" + "Store:" + this.nStore);
}
}
能用的,采纳了吧~~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |