-1
我的问题相对简单:我将如何去实现C++代码中的UML序列图?我前几天正在读顺序图,我发现this example为参加研讨会的学生提供了一个课程。实现UML序列图
我该如何将这个图转化为一个程序?为了这个问题,让我们关注一个类,比如说EnrollInSeminar
控制器。我将如何去实施这个?
我想,这可能是这样的:
class EnrollInSeminar
{
public:
void Activate();
};
void EnrollInSeminar::Activate()
{
SecurityLogon logonUI{};
Student theStudent = logonUI.getStudent();
SeminarSelector seminarSelectorUI{};
Seminar seminar = seminarSelectorUI.getSeminar();
if (!seminar.isEligible(theStudent))
return;
theStudent.getSchedule().determineFit(seminar);
Fee fee = StudentFees.calculateFees(seminar, theStudent);
FeeDisplay feeUI{fee};
if (!feeUI.getVerification())
return;
seminar.enrollStudent(theStudent);
}
这是落实EnrollInSeminar
类的正确方法是什么?如果不是,我该怎么做?
我会建议你将你的图片转换为PNG并将其直接包含在你的问题中。 –
至于你的问题,我不太确定你的代码是否满足图中所示的所有生命期要求。您创建的所有实例在函数作用域的末尾被销毁。您可能需要放置更多范围块'{}'以满足析构函数调用的要求。 –
此图几乎无法读取。 –