exercise_9.md 638 字节
Newer Older
Y
Yuan Yuan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# 题目9

在ObjectOrientedBook类中,实现一个构造方法`public ObjectOrientedBook(String bookName, BookType type, int pages, double price, boolean recommended);`,方法的作用是在父类相同的构造方法的基础上,同时实现将recommended属性设置成参数中recommended的值。





## 答案

```java
public class ObjectOrientedBook extends Book {
    private boolean recommended;

    public ObjectOrientedBook(String bookName, BookType type, int pages, double price, boolean recommended) {
        super(bookName, type, pages, price);
        this.recommended = recommended;
    }

}


```

## 选项