//Program 7.2

//In my own words, such output is printed because

/*uni-directional arrow and line without arrow show Associations relationship.
 
 Concept of Associations : 
Association always focus on activities.
The teach(Course)is activity that links 2 classes and it will become one of the method of the class Lecturer.
Since there is an arrow pointed to class Course, 
We must define the object of Course as data member(using pointer variable) in enclosing data in class Lecturer. 
Associations always declare attributes as object pointer and allow object to call methods through pointer variable.
Below shows object of Lecturer class call methods in Course class through pointer variable, C.

 Output Explanation:
When we call this print() function of class Lecturer, actually we will call getName() function of the class Course.
We can call this method from Course class because 
we already have pointer object (Course *C) that we already defined as data member for class Lecturer.
Because of Associations, we declare the object of class Course as object pointer(in private) in the class Lecturer.
void Lecturer::print()
{
	cout<<name<<" lectures "<< C->getName()<<endl;
}
Firstly, we can directly write name without adding pointer because 
name is the private member variable in class Lecturer that can be accessed using method in class Lecturer.
Words "lecturer" is print because we use cout<<" ", it is just a simple and normal way to print a word.
Secondly, in order to link 2 classes, we apply pointer concept.
We have to declare C (pointer variable) with dataType Course as data member in emclosing class,
when we want to access the public member of Course, we have to use this pointer variable to call.*/

#include<iostream>
using namespace std;

class Course
{
	private:
		string name,code;
		int section;
	
	public:
		Course(string name,string code,int section);
		string getName();
};

Course::Course(string name,string code,int section)
{
	this->name=name;
	this->code=code;
	this->section=section;
}

string Course::getName()
{
	return name;
}

class Lecturer
{
	private:
		string name;
		Course *C;
		
	public:
		Lecturer(string name);
		void teach(Course *subject);
		void print();
};

Lecturer::Lecturer(string name)
{
	this->name=name;
}

void Lecturer::teach(Course *subject)
{
	C=subject;
}

void Lecturer::print()
{
	cout<<name<<" lectures "<< C->getName()<<endl;
}


int main()
{
	Course *subj=new Course("Software Testing","SCSJ3343",1);
	Lecturer lect1("Radziah Mohammad");
	lect1.teach(subj);
	lect1.print();
	
	return 0;
}

