Question
Given a C++ program named program2.cpp that four classes named Course, Teacher and Exercises, respectively. Analyze the program and answer the following questions: a. Identify
Given a C++ program named program2.cpp that four classes named Course, Teacher and Exercises, respectively. Analyze the program and answer the following questions:
a. Identify the types of relationship between Teacher and Course classes and the relationship between Exercises and Course classes
b. Define the meaning of different type of relationship implemented in object-oriented programming as stated below:
i. Composition
ii. Aggregation
iii. Inheritance c
C. Complete the UML diagram in Figure 2 by drawing the correct notations that match the type of relationship identified in.
d. Afterwards, convert the content in program2.cpp in the same UML diagram drawed for (c) by filling in each class's attributes and methods completely.
e. Differentiate between association, aggregation and composition by giving an example of each of them
Note: As for question (a) until (e), write your answers in the answer_booklet.docx file provided. Alternatively, you may also write answers on papers and take snapshots of them with your smartphone.
#include #include using namespace std;
class Teacher { private: string lastName; string firstName; string officeNumber; public:
Teacher() { set("", "", ""); }
Teacher(string lname, string fname, string office) { set(lname, fname, office); }
void set(string lname, string fname, string office) { lastName = lname; firstName = fname; officeNumber = office; }
void print() const { cout cout cout };
class Exercises { private: string title; // Book title string author; // Author name string publisher; // Publisher name public:
Exercises() { set("", "", ""); }
Exercises(string textTitle, string auth, string pub) { set(textTitle, auth, pub); }
void set(string textTitle, string auth, string pub) { title = textTitle; author = auth; publisher = pub; } void print() const { cout cout cout };
class Course { private: string courseName; Teacher teacher; Exercises exercise; public: Course(string course, string teaLastName, string teaFirstName, string teaOffice, string textTitle, string author, string publisher) { courseName = course; teacher.set(teaLastName, teaFirstName, teaOffice); exercise.set(textTitle, author, publisher); }
void print() const { cout cout teacher.print(); cout exercise.print(); cout } };
int main() { Course myCourse("Programming Technique II", "Ali", "Hassan", "N28L501", "Object-oriented Programming Approach using C++", "Gilberg", "Springer");
myCourse.print(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started