测试时序图是否正常

master
高宏宇 2 years ago
parent 077bf58a44
commit 6da9e6fbcf

@ -0,0 +1,432 @@
## 1. Inheritance继承 and Polymorphism多态
> Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common features. What is the best way to design these classes so to avoid redundancy? The answer is to use inheritance.
### 1.1. 如何降低描述荣誉
如何降低代码的冗余例如在C语言中通过什么方式降低代码的冗余。
在C语言中降低代码冗余增加代码复用性一般使用函数来实现但是函数是一个高纬度的抽象和我们日常生活联系并不紧密。那么我们考虑日常生活中的例子。
通常我们描述一猫,只用说明猫是:界:动物界;门:脊椎动亚门;纲:哺乳纲;目:食肉目;科:猫科;属:猫属;种:猫种。
![Alt text](img/%E7%94%9F%E7%89%A9%E5%88%86%E7%B1%BB.drawio.svg)
上述的图表示物种分类的一部分。这样描述一个物种的分类有很多好处:
1. 清楚表明了祖先与后代的关系(继承树);
2. 后代具备祖先的所有特性;
3. 明确不同种之间的关系。
如果大家都清楚上述的规则当我们讨论猫种的时候就默认猫种具备祖先的所有特性而不必再说明猫种是脊椎动物胎生等这些它祖先所具备的特性。这种特性在Java种的类种也存在这就是继承。
### 1.2. Java中的继承
例如要在平面上描述两个类圆和矩形那么这两个类好像有一些基本的特性是一致的。例如填充颜色color是否填充 filled对象创建时间 dateCreated等。另外需要对上述属性设置或者读取的方法getColor()setColor()isFilled()setFilled()等。
如果每个类都需要描述所有的这些特性好像有点浪费如何做到降低代码冗余我们使用到继承如下图表述GeometrocObject是父类保护所有子类共有的特性数据和方法Circle和Rectangle继承于GeometrocObject。这样在编写Circle和Rectangle的时候就只需要对其特性进行描述就可以了这两个类的共性在其父类中以及体现出来了子类完全继承父类的所有特性数据和方法
![image-20230311122706219](img/image-20230311122706219.png)
代码实现如下:
#### 1.2.1. 父类
SimpleGeometricObject
```java
public class SimpleGeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
/** Construct a default geometric object */
public SimpleGeometricObject() {
dateCreated = new java.util.Date();
}
/**
* Construct a geometric object with the specified color and filled value
*/
public SimpleGeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}
/** Return color */
public String getColor() {
return color;
}
/** Set a new color */
public void setColor(String color) {
this.color = color;
}
/**
* Return filled. Since filled is boolean, its get method is named isFilled
*/
public boolean isFilled() {
return filled;
}
/** Set a new filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Get dateCreated */
public java.util.Date getDateCreated() {
return dateCreated;
}
/** Return a string representation of this object */
public String toString() {
return "created on " + dateCreated + "\ncolor: " + color + " and filled: " + filled;
}
}
```
可以看到父类对共有的变量和方法进行了定义,虽然父类可以实例化,但是好像实例化父类并没有什么实际的意义。
**注意:这个类最好不能被实例化,因为没有意义。下一章将借用这个离职,并使其不能被实例化。**
#### 1.2.2. 子类Circle
CircleFromSimpleGeometricObject
```java
public class CircleFromSimpleGeometricObject extends SimpleGeometricObject {
private double radius;
public CircleFromSimpleGeometricObject() {
}
public CircleFromSimpleGeometricObject(double radius) {
this.radius = radius;
}
public CircleFromSimpleGeometricObject(double radius, String color, boolean filled) {
this.radius = radius;
setColor(color);
setFilled(filled);
}
/** Return radius */
public double getRadius() {
return radius;
}
/** Set a new radius */
public void setRadius(double radius) {
this.radius = radius;
}
/** Return area */
public double getArea() {
return radius * radius * Math.PI;
}
/** Return diameter */
public double getDiameter() {
return 2 * radius;
}
/** Return perimeter */
public double getPerimeter() {
return 2 * radius * Math.PI;
}
/* Print the circle info */
public void printCircle() {
System.out.println("The circle is created " + getDateCreated() + " and the radius is " + radius);
}
}
```
1. 子类Circle使用`extend SimpleGeometricObject`表明继承于`SimpleGeometricObject`那么子类拥有父类的所有特性(数据和方法);
2. 但是请注意,虽然子类拥有父类的所有特性,不意味子类就可以无限制的访问这些特性,例如`color``filled``dateCreated` 这些是父类的私有变量在子类中并不能访问而要通过对应的getter和setter函数访问这些函数是公开的
3. `CircleFromSimpleGeometricObject`增加了自己的特性`radius`并设置成私有以及对应的getter和setter函数
4. 子类中增加了自己的行为:`getArea()`、`getPerimeter`和`printCircle()`
5. 当然,子类型的构造函数也不一样了,这是另外一个话题,后面会讲解。
#### 1.2.3. 子类
RectangleFromSimpleGeometricObject
```java
public class RectangleFromSimpleGeometricObject extends SimpleGeometricObject {
private double width;
private double height;
public RectangleFromSimpleGeometricObject() {
}
public RectangleFromSimpleGeometricObject(double width, double height) {
this.width = width;
this.height = height;
}
public RectangleFromSimpleGeometricObject(double width, double height, String color, boolean filled) {
this.width = width;
this.height = height;
setColor(color);
setFilled(filled);
}
/** Return width */
public double getWidth() {
return width;
}
/** Set a new width */
public void setWidth(double width) {
this.width = width;
}
/** Return height */
public double getHeight() {
return height;
}
/** Set a new height */
public void setHeight(double height) {
this.height = height;
}
/** Return area */
public double getArea() {
return width * height;
}
/** Return perimeter */
public double getPerimeter() {
return 2 * (width + height);
}
}
```
RectangleFromSimpleGeometricObject也使用同样的方式继承于SimpleGeometricObject只是新增的变量和方法不太一样。
#### 1.2.4. 测试主类
TestCircleRectangle
```java
public class TestCircleRectangle {
public static void main(String[] args) {
CircleFromSimpleGeometricObject circle = new CircleFromSimpleGeometricObject(1);
System.out.println("A circle " + circle.toString());
System.out.println("The color is " + circle.getColor());
System.out.println("The radius is " + circle.getRadius());
System.out.println("The area is " + circle.getArea());
System.out.println("The diameter is " + circle.getDiameter());
RectangleFromSimpleGeometricObject rectangle = new RectangleFromSimpleGeometricObject(2, 4);
System.out.println("\nA rectangle " + rectangle.toString());
System.out.println("The area is " + rectangle.getArea());
System.out.println("The perimeter is " + rectangle.getPerimeter());
}
}
```
通过测试程序,我们发现子类的对象引用变量上可以调用`toString()``getColor()` 等方法(这些方法是在父类中定义的),说明子类的确继承了父类的所有特性。
**思考一个问题:`getArea()`函数和`getPerimeter()`函数既然在两个子类中存在,就说明是这两个子类的共性;那为什么不把这两个函数写在父类当中?对了其实是因为他们的算法不同,虽然函数签名是一样的。下一章将要学习如何把这个方法放到父类中去。**
另外一个是`toString()`这个函数非常特别,后面会讲到。
## 2. 子类的构造函数
### 2.1. 构造函数也被继承了吗?
> No. They are not inherited.They are invoked explicitly or implicitly. Explicitly using the super keyword.
>
> A constructor is used to construct an instance of a class. Unlike properties and methods, a superclass's constructors are not inherited in the subclass. They can only be invoked from the subclasses' constructors, using the keyword super. If the keyword super is not explicitly used, the superclass's no-arg constructor is automatically invoked.
构造函数并不会被子类型所继承子类型通过显式或者隐式的方式调用父类的构造函数显式调用使用super关键字。如果没有显式调用那么子类型将隐式调用父类型不带参数的构造函数。
**为了便于子类型调用父类的构造函数,建议在定义类型的时候,要么不写构造函数,否则建议写一个不带参数的构造函数。**
A constructor may invoke an overloaded constructor or its superclasss constructor. If none of them is invoked explicitly, the compiler puts super() as the first statement in the . For example
![image-20230311222741376](img/image-20230311222741376.png)
![image-20230311222819514](img/image-20230311222819514.png)
父类如果只定义了带参数的构造函数那么Java不会分配不带参数的构造函数没有不带参数的构造函数这时如果子类没有显式调用父类带参数的构造函数将导致构造函数找不到的问题。
例如:
```java
class Person {
int age;
public Person(int a) {
age = a;
}
}
class Man extends Person {
}
```
上诉例子中定义的 Man 类将出现编译错误,因为 Person 缺少不带参数的构造函数Person 又没有显式的调用Person带参数的构造函数。修改 Man 类如下就可以了:
```java
class Man extends Person {
public Man() {
super(10);
}
}
```
### 2.2. super关键字
The keyword super refers to the superclass of the class in which super appears. This keyword can be used in three ways:
1. To call a superclass constructor
2. To call a superclass method
3. To access superclass fields
super关键字调用父类构造方法还可以理解为什么还需要super关键字去调用父类的函数和字段`CircleFromSimpleGeometricObject` 不是可以直接调用父类`SimpleGeometricObject`的方法吗?例如:`getColor()`等方法?
这是因为子类可以覆盖override父类的方法后面的覆盖父类方法的小节会讲解。
### 2.3. 构造函数链
当使用new关键字构建一个对象的时候如果这个对象所属的类有父类通常情况下都有那么是否和一步一步构建的我们看看下面的例子。
```java
public class Faculty extends Employee {
public static void main(String[] args) {
new Faculty();
}
public Faculty() {
super();
System.out.println("(4) Faculty's no-arg constructor is invoked");
}
}
class Employee extends PPP {
public Employee() {
this("(2) Invoke Employees overloaded constructor");
System.out.println("(3) Employee's no-arg constructor is invoked");
}
public Employee(String s) {
super();
System.out.println(s);
}
}
class PPP {
public PPP() {
System.out.println("(1) Person's no-arg constructor is invoked");
}
}
```
main函数开起来比较奇怪为什么在Faculty内中又使用new 方法构造自己所在的类其实大家不用太关心main函数在那里。首先因为java虚拟机要访问到这个静态函数作为程序的入口其次对于 main 函数只要被构建的类对于main函数来说是可以访问就行了。上述所有类型都定义在一个文件间当中这样如同是一个包因此main函数可以访问该文件中的所有类进而也可以访问 Faculty 类,构建 Faculty 类的对象当然也是可以的。其实把main函数放在这个文件的任何类中都是可以的只不过我们习惯放在 Faculty 这个类中(这个文档的文件名也是和这个类一致的)。
我们接下来仔细分析一下发生了什么,运行的结果是:
```
(1) Person's no-arg constructor is invoked
(2) Invoke Employees overloaded constructor
(3) Employee's no-arg constructor is invoked
(4) Faculty's no-arg constructor is invoked
```
也就是说PPP的构造函数被最先执行完成注意不是最先被调用然后是 Employee 的构造函数被执行完成,最后是 Faculty 的构造函数被执行完成。
```mermaid
sequenceDiagram
activate Faculty()
Faculty()->>Employee(): 显式调用super()
deactivate Faculty()
activate Employee()
Employee()->>PPP(): 隐式调用 PPP()
deactivate Employee()
activate PPP()
Note over PPP():1
PPP()->>Employee(): PPP()调用返回
activate Employee()
deactivate PPP()
Note over Employee():2、3
deactivate Employee()
Employee()->>Faculty():Employee()调用返回
activate Faculty()
Note over Faculty():4
deactivate Faculty()
```
## 3. Overriding 覆盖父类的方法
## 4. Overriding vs. Overloading
## 5. Object类
### 5.1. toString方法
## 6. Polymorphism多态
### 6.1. 动态函数绑定
## 7. 引用类型的类型转换
### 7.1. 子类型转换成父类型
### 7.2. 父类型转换成子类型
## 8. equals 方法
## 9. ArrayList类
## 10. protected 访问修饰
## 11. final 修饰

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

@ -0,0 +1,258 @@
<svg host="65bd71144e" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="461px" height="486px" viewBox="-0.5 -0.5 461 486" content="&lt;mxfile&gt;&lt;diagram id=&quot;N7akuFl0lC8h9WnHRuWj&quot; name=&quot;第 1 页&quot;&gt;3ZpNc6MgGMc/DdcdFVQ4mpd2L3vqYdujVRKdNZIhpEn20y8qJBpppu10JZpDAg+gPH9+PLxMAJxvjo883ma/WEoL4DnpEcAF8DwMifyuDKfGEIZOY1jzPG1M7sXwlP+lyqir7fOU7joVBWOFyLddY8LKkiaiY4s5Z4dutRUrum/dxmvaMzwlcdG3/s5TkSm3vPBi/0nzdabf7AbK4U2sKytPdlmcskPLBJcAzjljokltjnNaVNppXZp2D++UnjvGaSk+0kD1+C0u9so31S9x0s7SVPqusiUr5c8sE5tC5lyZ7L9Q9WHH9jxRj1APFTFfU1XLb0zVw1vNVCcfKdtQwU+yAqdFLPK3rvCxGr/1ud7FRZlQXr4jEf6kh/SYi2eZdn7ITjfZl1bRooLa0ZmTzpSyW00rX2df2mWXZnVOt/uqnMianOTLcob3K2dgS06vPx+XISBzQB7AMgCRA2a4tqDaEgJMQNQfAs72ZUpTpeshywV92sa1wwcZkbsjssqLYs4Kxuu2MI0pXiXSvhOc/aGtkiDB9HV1S9Y3ygU93pRMlXpERcCTDu0qf2gFVGXKWrEUOt8gstMT7KPM3gmyqI+sXhstMBuOPqIa9LQXA5AhBvgARyDClxlfxQBpnI9w6rv+1dTHw019+Nn9zd1Nfd+AKraFqm9AVa5SCODFJFDtrVJDojrEKvUh5AIDcsQWcsHEkUOePeTOg28dOb2b6exwXFvM6d50oMMAo2pVVvQtTYs0ASSsLOPD8HqR9hAcDsPRL9Ia1Q6+0Bq+evR7+EbyDInAjIAZNOErLRiQaAL4QscfDl84enyhAV97V0zQgK8EFNZXIJJjr+LVfESagWg5BXwDPBy+6G42AaZrDnsXx6ZzeVhtMqNZlYgkbv390/hYQ3DADac/+lBpOI+71q6OXNOB/MyoD2YuIFOIh4gMtxt1TSfO7rzHi2/VdIUTmhg1fcU+8m+y+XVNfX/ALVJf02f5GSGZyOIxCU9FxOtrtkFVJFNR8frm6D+qKLOX/yjUZa0/esDlPw==&lt;/diagram&gt;&lt;/mxfile&gt;">
<defs/>
<g>
<path d="M 290 30 L 290 73.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 290 78.88 L 286.5 71.88 L 290 73.63 L 293.5 71.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<path d="M 270 30 L 155.88 77.55" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 151.03 79.57 L 156.15 73.65 L 155.88 77.55 L 158.84 80.11 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<path d="M 310 30 L 414.2 77.36" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 418.98 79.54 L 411.16 79.83 L 414.2 77.36 L 414.06 73.45 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="250" y="0" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 15px; margin-left: 251px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
真核生物
</div>
</div>
</div>
</foreignObject>
<text x="290" y="19" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
真核生物
</text>
</switch>
</g>
<path d="M 150 110 L 150 136.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 150 141.88 L 146.5 134.88 L 150 136.63 L 153.5 134.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<path d="M 130 110 L 45.98 140.81" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 41.05 142.62 L 46.42 136.92 L 45.98 140.81 L 48.83 143.49 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="110" y="80" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 95px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
动物界
</div>
</div>
</div>
</foreignObject>
<text x="150" y="99" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
动物界
</text>
</switch>
</g>
<path d="M 290 110 L 290 136.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 290 141.88 L 286.5 134.88 L 290 136.63 L 293.5 134.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="250" y="80" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 95px; margin-left: 251px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
植物界
</div>
</div>
</div>
</foreignObject>
<text x="290" y="99" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
植物界
</text>
</switch>
</g>
<path d="M 420 110 L 420 136.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 420 141.88 L 416.5 134.88 L 420 136.63 L 423.5 134.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="380" y="80" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 95px; margin-left: 381px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
植物界
</div>
</div>
</div>
</foreignObject>
<text x="420" y="99" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
植物界
</text>
</switch>
</g>
<path d="M 150 173 L 150 198.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 150 203.88 L 146.5 196.88 L 150 198.63 L 153.5 196.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="110" y="143" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 158px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
脊椎动物门
</div>
</div>
</div>
</foreignObject>
<text x="150" y="162" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
脊椎动物门
</text>
</switch>
</g>
<path d="M 150 235 L 150 261.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 150 266.88 L 146.5 259.88 L 150 261.63 L 153.5 259.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="110" y="205" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 220px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
脯乳动物刚
</div>
</div>
</div>
</foreignObject>
<text x="150" y="224" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
脯乳动物刚
</text>
</switch>
</g>
<path d="M 150 298 L 150 323.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 150 328.88 L 146.5 321.88 L 150 323.63 L 153.5 321.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="110" y="268" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 283px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
食肉动物目
</div>
</div>
</div>
</foreignObject>
<text x="150" y="287" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
食肉动物目
</text>
</switch>
</g>
<path d="M 150 360 L 150 386.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 150 391.88 L 146.5 384.88 L 150 386.63 L 153.5 384.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="110" y="330" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 345px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
猫科
</div>
</div>
</div>
</foreignObject>
<text x="150" y="349" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
猫科
</text>
</switch>
</g>
<path d="M 150 423 L 150 448.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/>
<path d="M 150 453.88 L 146.5 446.88 L 150 448.63 L 153.5 446.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/>
<rect x="110" y="393" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 408px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
猫属
</div>
</div>
</div>
</foreignObject>
<text x="150" y="412" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
猫属
</text>
</switch>
</g>
<rect x="110" y="455" width="80" height="30" rx="4.5" ry="4.5" fill="#f8cecc" stroke="#b85450" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 470px; margin-left: 111px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
猫种
</div>
</div>
</div>
</foreignObject>
<text x="150" y="474" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
猫种
</text>
</switch>
</g>
<rect x="0" y="143" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 158px; margin-left: 1px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
XXXX
</div>
</div>
</div>
</foreignObject>
<text x="40" y="162" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
XXXX
</text>
</switch>
</g>
<rect x="250" y="143" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 158px; margin-left: 251px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
XXXX
</div>
</div>
</div>
</foreignObject>
<text x="290" y="162" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
XXXX
</text>
</switch>
</g>
<rect x="380" y="143" width="80" height="30" rx="4.5" ry="4.5" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/>
<g transform="translate(-0.5 -0.5)">
<switch>
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;">
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 78px; height: 1px; padding-top: 158px; margin-left: 381px;">
<div data-drawio-colors="color: rgb(0, 0, 0); " style="box-sizing: border-box; font-size: 0px; text-align: center;">
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">
XXXX
</div>
</div>
</div>
</foreignObject>
<text x="420" y="162" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">
XXXX
</text>
</switch>
</g>
</g>
<switch>
<g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/>
<a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank">
<text text-anchor="middle" font-size="10px" x="50%" y="100%">
Text is not SVG - cannot display
</text>
</a>
</switch>
</svg>

After

Width:  |  Height:  |  Size: 22 KiB

@ -11,8 +11,8 @@
3. 第三章:类与对象
1. [类与对象](03%EF%BC%9A%E7%B1%BB%E4%B8%8E%E5%AF%B9%E8%B1%A1/01.md)
2. [面向对象思维](03%EF%BC%9A%E7%B1%BB%E4%B8%8E%E5%AF%B9%E8%B1%A1/02.md)
3. 继承与多态
4. 抽象类与接口
3. [继承与多态](03%EF%BC%9A%E7%B1%BB%E4%B8%8E%E5%AF%B9%E8%B1%A1/04.md)
4. [抽象类与接口](03%EF%BC%9A%E7%B1%BB%E4%B8%8E%E5%AF%B9%E8%B1%A1/05.md)
4. 第四章:异常处理
5. 第五章IO编程
6. 第六章:集合与框架

Loading…
Cancel
Save