-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並將其直接包含在你的問題中。 –
至於你的問題,我不太確定你的代碼是否滿足圖中所示的所有生命期要求。您創建的所有實例在函數作用域的末尾被銷燬。您可能需要放置更多範圍塊'{}'以滿足析構函數調用的要求。 –
此圖幾乎無法讀取。 –