Looking for Course 20641 test answers and solutions? Browse our comprehensive collection of verified answers for Course 20641 at moodle.uleth.ca.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
You will refactor the design from Part (a) so that the formatting behaviour is implemented usingkind string.
Goal: No if/else/switch may be used to select the message-type behaviour.
Required output format rules:
EMAIL to <user>: <text>
SMS to <user>: <text> (truncate text to 20 characters)
PUSH to <user>: <optional URGENT><text>(if priority ≥ 4, add
URGENT before the text)Task: Complete the code template below by writing the missing class hierarchy. You must only fill the TODO sections.
#include <iostream>
#include <string>
#include <memory>
#include <array>
using namespace std;
// =====================
// TODO 1: Base class
// =====================
// Create an abstract class named MessageBase with:
// - a virtual destructor
// - virtual string format() const = 0;
// =====================
// TODO 2: Derived classes
// =====================
// Implement these derived classes (each must override format()):
// - EmailMessage
// - SMSMessage
// - PushMessage
//
// Each derived class should store the data it needs (user, text, priority if needed).
// Do NOT store a "kind" field in the polymorphic design.
int main() {
// Do not change main()
array<unique_ptr<MessageBase>, 3> msgs = {
make_unique<EmailMessage>("u100", "Welcome to the system", 2),
make_unique<SMSMessage>("u101", "Your verification code is 123456", 3),
make_unique<PushMessage>("u102", "Server maintenance tonight", 5)
};
for (const auto& m : msgs) {
cout << m->format() << "\n";
}
}
Expected output:
EMAIL to u100: Welcome to the system
SMS to u101: Your verification code
PUSH to u102: URGENT Server maintenance tonight
Constraints (must follow):
if/else/switch) is allowed to select the message type behavior.
dynamic_cast and no typeid.
array<unique_ptr<MessageBase>> to demonstrate polymorphism.Part B-1: Relationship Justification (Manual Grading)
For each relationship below, explain your reasoning in one sentence only.
Constraints:
Video Streaming Service (Scenario)
Answer the following based on the scenario:
Select one or more:
In the MediSched system, explain the reasoning behind the relationship between Schedule Appointment and Insurance Verification.
Focus your answer on how these two use cases interact in the system.
Maximum length: 100 words.
Match each version control concept to its correct description.
In the MediSched system, explain the reasoning behind the relationship between Make Payment and the payment-specific use cases.
Focus your answer on how different payment options relate to the overall payment functionality.
Maximum length: 100 words.
In the MediSched system, explain the reasoning behind the relationship between Cancel Appointment and Refund Request.
Focus your answer on when and why a refund request occurs.
Maximum length: 100 words.