永发信息网

创建book类.并为其编写两个构造方法

答案:2  悬赏:20  手机版
解决时间 2021-02-20 22:18
  • 提问者网友:你独家记忆
  • 2021-02-20 01:14
程序没学好。不知道怎么写了,求帮助

package book;


public class Book {
private String title;
private String press;
private String ISBN;
private double price;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPress() {
return press;
}
public void setPress(String press) {
this.press = press;
}
public String getISBN() {
return ISBN;
}
public void setISBN(String iSBN) {
ISBN = iSBN;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public Book() {
}
public Book(String bookTitle,String bookPress,String bookISBN,double bookPrice)
{
title=bookTitle;
press=bookPress;
ISBN=bookISBN;
price=bookPrice;

System.out.println(title);
System.out.println(press);
System.out.println(ISBN);
System.out.println(price);
}
}
最佳答案
  • 五星知识达人网友:渊鱼
  • 2021-02-20 02:18
程序没学好。不知道怎么写了,求帮助

package book;


public class Book {
    private String title;
    private String press;
    private String ISBN;
    private double price;
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getPress() {
        return press;
    }
    public void setPress(String press) {
        this.press = press;
    }
    public String getISBN() {
        return ISBN;
    }
    public void setISBN(String iSBN) {
        ISBN = iSBN;
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public Book()  {
    }
    public Book(String bookTitle,String bookPress,String bookISBN,double bookPrice)
    {
        title=bookTitle;
        press=bookPress;
        ISBN=bookISBN;
        price=bookPrice;

    System.out.println(title);
    System.out.println(press);
    System.out.println(ISBN);
    System.out.println(price);
    }

    public static void main(String args[]){
        Book b = new Book("AAAA","------","FFFF",8)
    }
}
全部回答
  • 1楼网友:酒者煙囻
  • 2021-02-20 03:12
public void book{ //两个属性 private string name; private int pages; //构造方法,初始化两个属性值 pubic book(){ name = "匿名"; pages = 0; } }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯