更新时间:2023-09-24 13:15:28
与您的设计没有冲突.AttendanceEvent
的每个具体实现只包含一个 AttendanceCode
的具体实现.PublicLeave
总是带有 PublicAttendanceCode
和 PrivateLeave
总是带有 PrivateAttendanceCode
Theres no conflict with your design. Each concrete implementation of AttendanceEvent
contains exactly one concrete implemenation of AttendanceCode
. PublicLeave
always w/ PublicAttendanceCode
and PrivateLeave
always w/ PrivateAttendanceCode
只要适当地编写您的函数体,一切都会好起来的.
Just write your function bodies appropriately and everything will be fine.
每当您为 PublicLeave
实例化或传入 AttendanceCode
时,请确保它是一个 PublicAttendanceCode
.同样,每当您为 PublicLeave
实例化或传入 AttendanceCode
时,请确保它是一个 PrivateAttendanceCode
Whenever you instantiate or pass in an AttendanceCode
for PublicLeave
make sure it is a PublicAttendanceCode
. Likewise, whenever you instantiate or pass in an AttendanceCode
for PublicLeave
make sure it is a PrivateAttendanceCode
您的构造函数示例看起来不错.在它的正文中,但类似于
Your constructor example looks just fine. In the body of it, but something like
public PubliLeave(PublicAttendanceCode code, DateTime startDateTime, DateTime endDateTime)
{
AttendanceCode = code;
StartDateTime = startDateTime; EndDateTime = endDateTime;
}
我唯一建议的是您更改一些名称,其中太多名称看起来相似.(例如 - 将参数设置为上述构造函数 sDateTimeIn、eDateTimeIn
或其他内容,并将 AttendanceCode
成员命名为类似于 myCode
而不是将其与班级名称)
The only thing I would suggest is that you change some names, too many of them look alike. (ex - make the arguments to above constructor sDateTimeIn, eDateTimeIn
or somethin, and name the AttendanceCode
member something like myCode
instead of having it identical to the class's name)