在另一个类

时间:2016-04-10 15:25:20

标签: java

我在.Author

中有这个构造
package author;

public class Author {
    private String name;
    private String email;
    private char gender;

    public Author (String name, String email, char gender) {
        this.name = name;
        this.email = email;
        this.gender = gender;
    }
    public String getName () {
        return name;
    }
    public char gender () {
        return gender;
    }
    public String getEmail () {
        return email;
    }
    public void SetEmail (String userEmail) {
        email = userEmail; 
    }
    public String toString () {
        return "Author info: " + " [name: " +name + ", " + " gender: " + gender +", " + " email " + email + "]";
    }

}

我有另一个名为.Book的类,我想在.Book内的另一个构造中使用Author构造中的“name”变量,如下所示:

public class Book {
    private String bookName;
    private String author;
    private double price;
    private int qty;

    public Book (String bookName, Author name, double price) {
        this.bookName = bookName;
        // here I'm getting an error saying ";" required
        this.author = Author name;
        this.price = price;
    }

}

我收到一个错误(显示在第二个代码中),所以显然我做得不对,不知道怎么做。有什么帮助吗?

0 个答案:

没有答案