[ create a new paste ] login | about

Link: http://codepad.org/A28BMC7c    [ raw code | output | fork ]

C++, pasted on Nov 1:
#include <iostream>
#include <sstream>
#include <fstream>
#include <ctime>
#include "Bunny.h"
#include "BunnyManager.h"
#include <vector>
using namespace std;

Bunny::Bunny()
{
}

Bunny::Bunny(string inputname, bool isfemale, string furcolor, bool isradioactive)
{
	name=inputname;
	isFemale=isfemale;
	color=furcolor;
	isRadioactive=isradioactive;
	age=0;
	isAlive=true;
	isAdult=false;
	bunnyPlaceHolder=' ';
	isMarkedRadioactive=false;
}

string Bunny::ToString()
{
	if(isAlive)
	{
		char agetostr[20];
		sprintf(agetostr, "%d", GetAge());
		string outputString= "\n Bunny " +  GetName() + " is: \n\t" + agetostr + " years old \n\t" + GetGenderAsText() + "\n\t" + GetColor() + "\n\t" + GetRadioactiveAsText() + "\n";
		return outputString;
	}
	else
	{	
		string outputString="Bunny " + GetName() + " is DEAD \n ";
		return outputString;
	}
	cout<<"\n \n";
}

string Bunny::GetName()
{
	return name;
}

string Bunny::GetGenderAsText()
{
	string gender;
	if(isFemale)
	{	
		gender="Female";
	}
	else
	{
		gender="Male";
	}
	return gender;
}

string Bunny::GetColor()
{
	return color;
}

string Bunny::GetRadioactiveAsText()
{
	string radioactive;
	if(isRadioactive)		
		radioactive="Radioactive Mutant Vampire Bunny has emerged!";
	else
		radioactive="";
	return radioactive;
}

bool Bunny::GetIsFemale()
{
	return isFemale;
}

bool Bunny::GetIsAlive()
{
	return isAlive;
}

bool Bunny::GetisAdult()
{
	return isAdult;
}

bool Bunny::GetisRadioactive()
{
	return isRadioactive;
}

bool Bunny::SetIsAlive()
{
	if (age>=10 && !isRadioactive)
	{	
		isAlive=false;
	}
	else if (age>=50)
	{
		isAlive=false;
	}
	else
	{
		isAlive=true;
	}
	return isAlive;
}

int Bunny::GetAge()
{
	return age;
}

int Bunny::IncrementAge()
{
	if(isAlive)
		age++;

	if((age>=10 && !isRadioactive) ||(age>=50 && isRadioactive))
	{
		isAlive=false;
	}
	if (age>=2)
	{
		isAdult=true;
	}
	else
	{
		isAdult=false;
	}
	return age;
}

void Bunny::SetIsAliveFalse()
{
	isAlive=false;
}

void Bunny::SetIsRadioactiveTrue()
{
	isRadioactive=true;
}

Coordinates Bunny::GetLocation()
{
	return location;
}

void Bunny::SetLocation(Coordinates newLocation)
{
	location.SetX(newLocation.GetX());
	location.SetY(newLocation.GetY());
}

char Bunny::GetBunnyPlaceHolder()
{
	return bunnyPlaceHolder;
}

void Bunny::SetBunnyPlaceHolder(Bunny currentBunny)
{
	
	if(	currentBunny.GetIsFemale() && 
		!currentBunny.GetisRadioactive() && 
		!currentBunny.GetisAdult())
		{
			bunnyPlaceHolder='f';
		}
		else if(!currentBunny.GetisRadioactive() && 
				!currentBunny.GetisAdult())
		{
			bunnyPlaceHolder='m';
		}
		else if(currentBunny.GetIsFemale() && 
				!currentBunny.GetisRadioactive() && 
				currentBunny.GetisAdult())
		{
			bunnyPlaceHolder='F';
		}
		else if(!currentBunny.GetisRadioactive() && 
				currentBunny.GetisAdult())
		{
			bunnyPlaceHolder='M';
		}
		else
		{
			bunnyPlaceHolder='X';
		}
}

bool Bunny::GetIsMarkedRadioactive()
{
	return isMarkedRadioactive;
}

void Bunny::SetIsMarkedRadioactive(bool isMarked)
{
	isMarkedRadioactive=isMarked;
}


Output:
1
2
3
4
Line 18: error: Bunny.h: No such file or directory
Line 25: error: BunnyManager.h: No such file or directory
Line 10: error: 'Bunny' has not been declared
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: