日期:2014-05-20 浏览次数:20781 次
public class NewBook1 {
String gname;
int gid;
float gprice;
public void print()
{
System.out.println("该商品的名字为"+gname+",ID号"+gid+",价格是"+gprice);
}
public NewBook1(String name,int id,float price)
{
gname=name;
gid=id;
gprice=price;
}
public static void main(String args[])
{
NewBook1 book1=new NewBook1("《他的国》",21001,25.0F);
book1.print();
NewBook1 book2=new NewBook1("《小时代》",21002,29.8F);
book2.print();
}
}