public class shu {
private String shuming;//书名
private String leixing;//类型
private String zuozhe;//作者
private String jiage;//价格
public shu(String shuming,String leixing,String zuozhe,String jiage)//利用构造方法初始化
{
this.shuming =shuming;
this.leixing = leixing;
this.zuozhe = zuozhe;
this.jiage = jiage;
}
public String getShuming()
{
return shuming;
}
public String getLeixing()
{
return leixing;
}
public String getZuozhe()
{
return zuozhe;
}
public String getJiage()
{
return jiage;
}
}
public class book {
public static void main(String[] args) {
shu book = new shu("惊悚乐园","奇幻灵异","三天两觉","24");
System.out.println("书名:"+book.getShuming());
System.out.println("类型:"+book.getLeixing());
System.out.println("作者:"+ book.getZuozhe());
System.out.println("价格:"+ book.getJiage()+"元");
}
}