You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
723 B

@startuml
' 形状类图
' 抽象类 Shape
abstract class Shape {
+ getArea(): double
}
' Circle 类
class Circle {
- radius: double
+ Circle(radius: double)
+ getArea(): double
}
' Rectangle 类
class Rectangle {
- width: double
- height: double
+ Rectangle(width: double, height: double)
+ getArea(): double
}
' Triangle 类
class Triangle {
- base: double
- height: double
+ Triangle(base: double, height: double)
+ getArea(): double
}
' ShapeUtil 工具类
class ShapeUtil {
+ printArea(shape: Shape): void
+ main(args: String[]): void
}
' 继承关系
Shape <|-- Circle
Shape <|-- Rectangle
Shape <|-- Triangle
' 使用关系
ShapeUtil --> Shape
@enduml