typstuff/misc/uml/main.typ

104 lines
2.2 KiB
Typst
Raw Normal View History

2024-12-13 23:04:02 +01:00
#import "uml.typ"
#set page(width: auto, height: auto, margin: 1cm)
#uml.diagram({
import uml: *
class("Person", abstract, {
attr("name", "str")
attr("phoneNumber", "str")
attr("emailAddress", "str")
method("purchaseParkingPass")
})
class("Address", {
attr("street", "str")
attr("city", "str")
attr("state", "str")
attr("postalCode", "int")
attr("country", "str")
method("validate", "bool", private)
method("outputAsLabel", "str")
})
class("Student", {
attr("studentNumber", "int")
attr("averageMark", "int")
method("isEligibleToEnroll", "bool", ("str",))
method("getSeminarsTaken", "int")
})
class("Professor", {
attr("salary", "int", package)
attr("staffNumber", "int", protected)
attr("yearsOfService", "int", private)
attr("numberOfClasses", "int")
})
})
#pagebreak()
#uml.diagram({
import uml: *
class("Pageable", interface, {
attr("UNKNOWN_N_OF_PAGES", "int", default: -1)
})
class("SQLStatement", {
method("executeQuery", "ResultSet", (sql: "String"))
method("isPoolable", "Boolean")
method("getQueryTimeout", "int")
method("clearWarnings")
})
class("SearchService", {
attr("config", "Configuration", private)
attr("engine", "SearchEngine", private)
method("search", "SearchResult", (query: "SearchRequest"))
method("createEngine", "SearchEngine", private, static)
})
class("SearchService", grouped: true, {
attr("config", "Configuration", private)
attr("engine", "SearchEngine", private)
method("search", "SearchResult", (query: "SearchRequest"))
method("createEngine", "SearchEngine", private, static)
})
})
#pagebreak()
#import "parser.typ": parse
#parse(```
@class-grouped=true
class Button {
-theController : Controller*
+press() : void
+setTheController(p : Controller*) : void
}
abstract class Controller {
-theLight : Light*
-lampState : boolean
+evButtonPressed() : void
+setTheLight(p : Light*) : void
-toggle() : void
}
class Light {
+on() : void
+off() : void
}
```)
#pagebreak()
#parse(```
class City {
+resources: HashMap[ResourceType, Int]
+globalHappiness: Double
}
abstract class Building {
+getResourcesOnBuilt(): HashMap[ResourceType, Int]
}
```)