Exemplo n.º 1
0
int main( int argc, char *argv[] )
{
	Cd 	c1("Beatles", "Capitol", 14, 35.5);
	Classic c2 = Classic("Alfred Brendel", "Philips", 2, 57.17, 
				"Piano Sonata in B flat, Fantasia in C");
	Cd 	* pcd = &c1;

	cout << "Using object directly:\n";
	c1.Report();
	c2.Report();

	cout << "Using type cd * poinyer to objects:\n";
	pcd->Report();
	pcd = &c2;
	pcd->Report();

	cout << "Calling a function with a Cd reference argument:\n";
	Bravo(c1);
	Bravo(c2);

	cout << "Testing assignment: ";
	Classic copy;
	copy = c2;
	copy.Report();

	return 0;
}
Exemplo n.º 2
0
int main() {

	Cd c1("Beatles", "Capitol", 14, 35.5);
	Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", "Alfred Brendel", "Philips", 2, 57.17);

	Cd *pcd = &c1;

	cout << "Using object directly: \n";
	c1.report(); // use Cd method
	c2.report(); // use Classic method

	cout << "Using type cd * pointer to objects:\n";
	pcd->report(); // use cd method for cd object
	pcd = &c2;
	pcd->report(); // use Classic method for classic object

	cout << "Calling a function with a Cd reference argument:\n";
	bravo(c1);
	bravo(c2);


	cout << "Testing assignment: ";
	Classic copy;
	copy = c2;
	copy.report();

	system("pause");
	return 0;
}
Exemplo n.º 3
0
int main()
{
	Cd c1("Beatles", "Capitol", 14, 35.5);
	Classic c2 = Classic("Sonata fortepianowa B-dur, Fantazja C-moll", "Alfred Brendel", "Philips", 2, 57.17);
	
	Cd * pcd = &c1;

	std::cout << "Direct usage of the object:\n";
	c1.Report();	//uses Cd::Report()
	std::cout << std::endl;
	c2.Report();	//uses Classic::Report()

	std::cout << "\nUsage of pointer to Cd:\n";
	pcd->Report();	//Cd::Report
	std::cout << std::endl;
	pcd = &c2;
	pcd->Report();	//Classic::Report()

	std::cout << "\nCalling a function with an argument as a reference to Cd type:\n";
	Bravo(c1);
	std::cout << std::endl;
	Bravo(c2);

	std::cout << "\nAssignment test:\n";
	Classic copy;
	copy = c2;
	copy.Report();
	
	return 0;
}
void Customer::displayHistory()
{

	HistoryData *curr = head;

	if (head == NULL) {
		cout << "No history for this customer" << endl;
		return;
	}

	while (curr != NULL)
	{
		cout << "DVD " << curr->transactionType << " ";

		Classic *classic = dynamic_cast<Classic*>(curr->movie);

		if (classic == NULL)
		{
			cout << curr->movie->getTitle() << " " << curr->movie->getDirector() << " " << curr->movie->getYear() << endl;
		}
		else
		{
			cout << classic->getTitle() << " " << classic->getDirector() << " " << classic->getYear() << " " << classic->getMonth() << " " << classic->getActor() << endl;
		}
	}
}
Exemplo n.º 5
0
int main(int nNumberofArgs, char* pszArgs[])
{
	//*  Variable Declaration


	//*  Main Code

	Cd c1("Beatles", "Capitol", 14, 35.5);
	Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C","Alfred Brendel", "Philips", 2, 57.17);
	Cd *pcd = &c1;
	
	cout << endl << endl;
	cout << "Using object directly:\n";
	c1.Report(); // use Cd method
	c2.Report(); // use Classic method
	
	cout << endl << endl;
	cout << "Using type cd * pointer to objects:\n";
	pcd->Report(); // use Cd method for cd object
	pcd = &c2;
	pcd->Report(); // use Classic method for classic object
	
	cout << endl << endl;
	cout << "Calling a function with a Cd reference argument:\n";
	Bravo(c1);
	Bravo(c2);
	
	cout << "Testing assignment: ";
	Classic copy;
	copy = c2;
	copy.Report();

	//*  Program End
	//   - wait until user is ready before terminating program
	//   - to allow the user to see the program results

	cout << endl << endl;
	system("PAUSE");
	return 0;
}
bool Customer::canBorrow(int id, string movieType, string action, string movieName, string directorName, int month, int year)
{
	HistoryData *curr = head;
	bool borrowNoReturn = false;

	if (movieType == "F") //////////////////////////////Comedy
	{
		//While youre not at the end of the list
		while (curr != NULL)
		{
			Comedy *comedy = dynamic_cast<Comedy*>(curr->movie);

			//Search through the history for the desired movie, if its been BORROWED
			if (curr->transactionType == action && comedy->getTitle() == movieName && comedy->getYear() == year)
			{
				//Found the movie in the customers history and they borrowed it, not sure if they returned it yet
				borrowNoReturn = true;
			}
			//Search through the history for the desired movie, if its been RETURNED
			else if (curr->transactionType != action && comedy->getTitle() == movieName && comedy->getYear() == year)
			{
				//Found the movie in the customers history and they returned it
				borrowNoReturn = false;
			}

			//Traverse the list
			curr = curr->next;
		}
	}
	else if (movieType == "D") /////////////////////////////////Drama
	{
		//While youre not at the end of the list
		while (curr != NULL)
		{
			Drama *drama = dynamic_cast<Drama*>(curr->movie);

			//Search through the history for the desired movie, if its been BORROWED
			if (curr->transactionType == action && drama->getDirector() == directorName && drama->getTitle() == movieName)
			{
				//Found the movie in the customers history and they borrowed it, not sure if they returned it yet
				borrowNoReturn = true;
			}
			//Search through the history for the desired movie, if its been RETURNED
			else if (curr->transactionType != action && drama->getDirector() == directorName && drama->getTitle() == movieName)
			{
				//Found the movie in the customers history and they returned it
				borrowNoReturn = false;
			}

			//Traverse the list
			curr = curr->next;
		}
	}
	else if (movieType == "C") //////////////////////////////////Classics
	{
		//While youre not at the end of the list
		while (curr != NULL)
		{
			Classic *classic = dynamic_cast<Classic*>(curr->movie);

			//Search through the history for the desired movie, if its been BORROWED
			if (curr->transactionType == action && classic->getDirector() == directorName && classic->getMonth() == month && classic->getYear() == year)
			{
				//Found the movie in the customers history and they borrowed it, not sure if they returned it yet
				borrowNoReturn = true;
			}
			//Search through the history for the desired movie, if its been RETURNED
			else if (curr->transactionType != action && classic->getDirector() == directorName && classic->getMonth() == month && classic->getYear() == year)
			{
				//Found the movie in the customers history and they returned it
				borrowNoReturn = false;
			}

			//Traverse the list
			curr = curr->next;
		}
	}

	//Return depending on if the movie has been borrowed and not returned or not borrowed at all
	if (borrowNoReturn == false)
	{
		return true;
	}
	else
	{
		return false;
	}
}