Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ref style #22

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ subtrees:
- file: ch-programming-basics/inheritance-and-polymorphism
- file: ch-programming-basics/generics
- file: ch-programming-basics/functional-programming
- file: ch-programming-basics/exercise-Flink-development-environment
- file: ch-programming-basics/exercise-dev-environment
- file: ch-system-design/index
entries:
- file: ch-system-design/dataflow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(exercise-Flink-development-environment)=
(exercise-dev-environment)=
# 案例实战 Flink 开发环境搭建

本案例实战主要带领读者完成对 Flink 开发环境的搭建。
Expand Down
16 changes: 10 additions & 6 deletions doc/ch-programming-basics/inheritance-and-polymorphism.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@

{numref}`extend` 所示为对动物进行的简单的建模。其中,每个动物都有一些基本属性,即名字(name)和描述(description);有一些基本方法,即 getName()和 eat(),这些基本功能共同组成了 Animal 类。在 Animal 类的基础上,可以衍生出各种各样的子类、子类的子类等。比如,Dog 类有自己的 dogData 属性和 bark()方法,同时也可以使用父类的 name 等属性和 eat() 方法。

我们将 {numref}`extend` 所示的 Animal 类继承关系转化为代码,一个 Animal 公共父类可以抽象如代码清单 2-1 所示。
我们将 {numref}`extend` 所示的 Animal 类继承关系转化为代码,一个 Animal 公共父类可以抽象如 {numref}`code-animal-class` 所示。

```{code-block} java
:caption: Animal 类
:name: code-animal-class

```java
public class Animal {

private String name;
Expand All @@ -32,8 +35,6 @@ public class Animal {
}
```

代码清单 2-1 一个简单的 Animal 类

```{figure} ./img/extend.png
---
name: extend
Expand All @@ -42,9 +43,12 @@ width: 60%
Animal 类继承关系
```

子类可以拥有父类非 private 的属性和方法,同时可以扩展属于自己的属性和方法。比如 Dog 类或 Fish 类可以继承 Animal 类,可以直接复用 Animal 类里定义的属性和方法。这样就不存在代码的重复问题,整个工程的可维护性更好。在 Java 和 Scala 中,子类继承父类时都要使用 extends 关键字。代码清单 2-2 实现了一个 Dog 类,并在里面添加了 Dog 类的一些特有成员。
子类可以拥有父类非 private 的属性和方法,同时可以扩展属于自己的属性和方法。比如 Dog 类或 Fish 类可以继承 Animal 类,可以直接复用 Animal 类里定义的属性和方法。这样就不存在代码的重复问题,整个工程的可维护性更好。在 Java 和 Scala 中,子类继承父类时都要使用 extends 关键字。{numref}`code-dog-class` 实现了一个 Dog 类,并在里面添加了 Dog 类的一些特有成员。

```{code-block} java
:caption: Dog 类
:name: code-dog-class

```java
public class Dog extends Animal implements Move {

private String dogData;
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
nb_execution_timeout = 30
nb_output_stderr = 'show'
numfig = True
numfig_format = {'figure': '图 %s', 'table': '表 %s', 'code-block': '代码片段 %s', 'section': '章节 %s'}
numfig_format = {'figure': '图 %s', 'table': '表 %s', 'code-block': '代码清单 %s', 'section': '章节 %s'}
pygments_style = 'sphinx'
suppress_warnings = ['myst.domains']
use_jupyterbook_latex = True
Expand Down
Loading