建立符合下列陈述的对象模型:某图书馆有许多名职员为之工作职员又进一步划分为馆长和管理员两类;馆长可对图书借阅工作进行管理每名管理员可管理多本图书每本图书可由多名管理员管理;图书拥有许多读者借书证号唯一地确定每一个读者;读者又可分为教师和学生两类每名教师或学生可以借阅数本图书每一种图书可供多名教师或学生借阅。给出UML代码
class Staff {
- id: int
- name: string
- position: string
}
class Librarian {
- id: int
- name: string
- position: string
- manageBorrowing(): void
}
class Administrator {
- id: int
- name: string
- position: string
- books: List<Book>
}
class Book {
- id: int
- title: string
- authors: List<string>
- administrators: List<Administrator>
- borrowers: List<Borrower>
}
class Borrower {
- id: int
- name: string
- type: string
- borrowingLimit: int
}
class Teacher {
- id: int
- name: string
- type: string
- borrowingLimit: int
- borrowedBooks: List<Book>
}
class Student {
- id: int
- name: string
- type: string
- borrowingLimit: int
- borrowedBooks: List<Book>
}
Staff <|-- Librarian
Staff <|-- Administrator
Borrower <|-- Teacher
Borrower <|-- Student
其中,箭头表示继承关系,|-- 表示继承,<>-- 表示关联关系
原文地址: https://www.cveoy.top/t/topic/fr6p 著作权归作者所有。请勿转载和采集!