Archives from S:\ Drive
Good to keep around methinks
This commit is contained in:
1 parent
eadaf70b9e
commit
6dd63cc439
606 files changed
+50212
No files matched your search
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PetSim", "PetSim\PetSim.vcproj", "{8101A427-427A-44DA-B178-193B89D7FD9F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8101A427-427A-44DA-B178-193B89D7FD9F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8101A427-427A-44DA-B178-193B89D7FD9F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8101A427-427A-44DA-B178-193B89D7FD9F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8101A427-427A-44DA-B178-193B89D7FD9F}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,192 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="PetSim"
|
||||
ProjectGUID="{8101A427-427A-44DA-B178-193B89D7FD9F}"
|
||||
RootNamespace="PetSim"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
GenerateDebugInformation="true"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pet.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\pet.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************
|
||||
* Author: Amrit Panesar ,o/ ASP *
|
||||
* Date: 06-19-2013 *
|
||||
* Program: PetSimulator *
|
||||
* File: main.cpp *
|
||||
* Function: MAIN *
|
||||
* Abstract: This file contains the main function which drives the app. *
|
||||
* contained in this file is the means of getting the initial value*
|
||||
* for the name field of the Pet class. This is contained in the *
|
||||
* while loop as seen below. *
|
||||
* Liscence: Released as Public Domain material. *
|
||||
****************************************************************************/
|
||||
|
||||
#include "Pet.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Function: int main(string[], int) *
|
||||
* Abstract: Drives the PetSimulator. Gets the initial value for the pet name *
|
||||
* from the user. This is contained in a loop so that if the user *
|
||||
* makes a mistake on the name for their pet, the user may correct *
|
||||
* their mistake without having to relaunch the program. *
|
||||
*****************************************************************************/
|
||||
int main()
|
||||
{
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
cout << "Welcome to Pet Simulator 2013 Console Edition" << endl << endl;
|
||||
cout << "To begin, we need a name for your pet" << endl;
|
||||
string petname = "";
|
||||
|
||||
//this loop allows the user to confirm and correct a mistake on their pet's name
|
||||
while (true)
|
||||
{
|
||||
cout << "What would you like your pet to be named?" << endl << ":";
|
||||
string in;
|
||||
cin >> in;
|
||||
cout << "You want to name your pet " << in << ". Is that correct?" << endl << ":[Y/n]";
|
||||
char choice;
|
||||
cin >> choice;
|
||||
petname = in;
|
||||
if (choice == 'Y' || choice == 'y')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
Pet thisPet(petname, 100, 0);
|
||||
thisPet.run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
/*****************************************************************************
|
||||
* Author: Amrit Panesar ,o/ ASP *
|
||||
* Date: 06-19-2013 *
|
||||
* Program: PetSimulator *
|
||||
* File: pet.cpp *
|
||||
* Function: Holds all functions pertaining to the pet class. *
|
||||
* Abstract: This file contains all necessary functions related to the Pet *
|
||||
* class as contained in the Pet.h header file. These functions *
|
||||
* were dictated as such in the project specifications. *
|
||||
* Liscence: Released as Public Domain material. *
|
||||
****************************************************************************/
|
||||
|
||||
#include "Pet.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Constructor - Pet(string, int, int) *
|
||||
* Abstract: Instantiates object. Three parameters are taken, name, hunger, *
|
||||
* and boredom. The constructor also prints the initial statistics *
|
||||
* of the pet. *
|
||||
*****************************************************************************/
|
||||
Pet::Pet (string name, int hunger, int boredom)
|
||||
{
|
||||
setName(name);
|
||||
setHungerLevel(0);
|
||||
setBoredomLevel(0);
|
||||
|
||||
displayPetBehavior();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Setter - setName(string) *
|
||||
* Abstract: Sets the name of the pet. *
|
||||
*****************************************************************************/
|
||||
void Pet::setName(string in)
|
||||
{
|
||||
name = in;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Getter - getName() *
|
||||
* Abstract: Gets the name of the pet. *
|
||||
*****************************************************************************/
|
||||
string Pet::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Setter - setBoredomLevel(int) *
|
||||
* Abstract: Sets the boredom level of the pet if the level is *
|
||||
* between 0 and 100 *
|
||||
*****************************************************************************/
|
||||
void Pet::setBoredomLevel(int in)
|
||||
{
|
||||
if (in >= 0 || in <= 100)
|
||||
{
|
||||
boredomLevel = in;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Getter - getBoredomLevel() *
|
||||
* Abstract: Gets the boredom level of the pet. *
|
||||
*****************************************************************************/
|
||||
int Pet::getBoredomLevel()
|
||||
{
|
||||
return boredomLevel;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Setter - setHungerLevel(int) *
|
||||
* Abstract: Sets the hunger level of the pet if the level is *
|
||||
* between 0 and 100 *
|
||||
*****************************************************************************/
|
||||
void Pet::setHungerLevel(int in)
|
||||
{
|
||||
if (in >= 0 || in <= 100)
|
||||
{
|
||||
hungerLevel = in;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Getter - getHungerLevel() *
|
||||
* Abstract: Gets the hunger level of the pet. *
|
||||
*****************************************************************************/
|
||||
int Pet::getHungerLevel()
|
||||
{
|
||||
return hungerLevel;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Menu *
|
||||
* Abstract: Does the thing. This is the main interface of the program. *
|
||||
* An enum is used to switch functionality for the interface. *
|
||||
* cin is used to gather input from the user. This function loops *
|
||||
* and calls getName, talk, feedpet and play. A GOTO is used as a *
|
||||
* means to exit from the while loop. This is a standard. *
|
||||
*****************************************************************************/
|
||||
void Pet::menu()
|
||||
{
|
||||
enum { TALK = 1, FEED, PLAY, QUIT };
|
||||
while (true)
|
||||
{
|
||||
cout << "Pet: " << getName() << endl;
|
||||
cout << TALK << ". Talk with your pet." << endl;
|
||||
cout << FEED << ". Feed your pet." << endl;
|
||||
cout << PLAY << ". Play with your pet." << endl;
|
||||
cout << QUIT << ". Quit your pet." << endl;
|
||||
cout << "What would you like to do?" << endl << ":";
|
||||
int menuSelection;
|
||||
cin >> menuSelection;
|
||||
//cls();
|
||||
switch (menuSelection)
|
||||
{
|
||||
case TALK:
|
||||
talk();
|
||||
break;
|
||||
case FEED:
|
||||
feedPet((((rand()%509)*(rand()%349))%4));
|
||||
break;
|
||||
case PLAY:
|
||||
play((((rand()%509)*(rand()%349))%4));
|
||||
break;
|
||||
case QUIT:
|
||||
break
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (memuSelection == QUIT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: FeedPet(int) *
|
||||
* Abstract: Feeds the pet. By default it will decrease the hungerlevel by *
|
||||
* one. If the food parameter is less-than or equal to 0 the *
|
||||
* food parameter becomes one. If the food parameter is greater *
|
||||
* than four, the food parameter becomes four. If the hunger level *
|
||||
* is less-than the food parameter, the hunger parameter is set to 0*
|
||||
*****************************************************************************/
|
||||
void Pet::feedPet(int food)
|
||||
{
|
||||
if (food > 4)
|
||||
{
|
||||
food = 4;
|
||||
}
|
||||
else if (food <= 0)
|
||||
{
|
||||
food = 1;
|
||||
}
|
||||
|
||||
if (getHungerLevel() < food)
|
||||
{
|
||||
setHungerLevel(getHungerLevel()-getHungerLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
setHungerLevel(getHungerLevel()-food);
|
||||
}
|
||||
|
||||
cout << getName() << " has been fed " << food << " pellets of food" << endl;
|
||||
passTime();
|
||||
displayPetBehavior();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: petmood() *
|
||||
* Abstract: Returns the boredomlevel + the hungerlevel of the pet. *
|
||||
*****************************************************************************/
|
||||
int Pet::petMood()
|
||||
{
|
||||
return getBoredomLevel() + getHungerLevel();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: passtime(int = 1) *
|
||||
* Abstract: Increases the hungerlevel and boredom level by the time param *
|
||||
*****************************************************************************/
|
||||
void Pet::passTime(int time)
|
||||
{
|
||||
setHungerLevel(getHungerLevel()+time);
|
||||
setBoredomLevel(getBoredomLevel()+time);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: displaypetbehavior() *
|
||||
* Abstract: Displays the statistics of the pet. This function will also *
|
||||
* display customized messages depending on the hunger and boredom *
|
||||
* levels of the pet. If the levels are less than 3, the pet is *
|
||||
* content. If the levels are between 3 and 11 the pet is a litle <>*
|
||||
* if the levels are greater than 11, the pet is very <>. *
|
||||
*****************************************************************************/
|
||||
void Pet::displayPetBehavior()
|
||||
{
|
||||
cout << " Boredom: " << getBoredomLevel() << endl;
|
||||
cout << " Hunger: " << getHungerLevel() << endl;
|
||||
if (getBoredomLevel() < 3 && getHungerLevel() < 3)
|
||||
{
|
||||
cout << getName() << " is content" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getBoredomLevel() >= 3 && getBoredomLevel() < 11)
|
||||
{
|
||||
cout << getName() << " is a litte bored" << endl;
|
||||
}
|
||||
else if (getBoredomLevel() >= 11)
|
||||
{
|
||||
cout << getName() << " is very bored" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
if ( getHungerLevel() >= 3 && getHungerLevel() < 11)
|
||||
{
|
||||
cout << getName() << " is a litte hungry" << endl;
|
||||
}
|
||||
else if (getHungerLevel() >= 11)
|
||||
{
|
||||
cout << getName() << " is very hungry" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: talk() *
|
||||
* Abstract: Displays the 'mood' of the pet. This function displays customized*
|
||||
* messages to the user depending on the return value of the petmood*
|
||||
* function. If the petmood is less than 7, the pet is feeling happy*
|
||||
* If the pet mood is between 6 and 16 then the pet is feeling okay *
|
||||
* If the pet mood is greater than 21 then the pet is feeling bad *
|
||||
*****************************************************************************/
|
||||
void Pet::talk()
|
||||
{
|
||||
if (petMood() < 7)
|
||||
{
|
||||
cout << getName() << " is feeling happy!" << endl;
|
||||
}
|
||||
else if (petMood() >= 7 && petMood() < 16)
|
||||
{
|
||||
cout << "\t" << getName() << " is feeling okay." << endl;
|
||||
}
|
||||
else if (petMood() >=16 && petMood() < 21)
|
||||
{
|
||||
cout << "\t" << getName() << " is feeling fustrated." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\t" << getName() << " is feeling mad!" << endl;
|
||||
}
|
||||
|
||||
passTime();
|
||||
displayPetBehavior();
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: play(int = 0) *
|
||||
* Abstract: Plays with the pet. by default it will decreade the hungerlevel *
|
||||
* by one. If the play parameter is lessthan or equalto 0 the play *
|
||||
* parameter becomes one. If the play parameter is greaterthan four *
|
||||
* then the play parameter becomes four. If the boredom level is *
|
||||
* lessthan the play parameter, the boredom parameter is set to zero*
|
||||
*****************************************************************************/
|
||||
void Pet::play(int play)
|
||||
{
|
||||
if (play > 4)
|
||||
{
|
||||
play = 4;
|
||||
}
|
||||
else if (play <= 0)
|
||||
{
|
||||
play = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
if (getBoredomLevel() < play)
|
||||
{
|
||||
setBoredomLevel(getBoredomLevel()-getBoredomLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
setBoredomLevel(getBoredomLevel()-play);
|
||||
}
|
||||
cout << getName() << " had " << play << " hours of fun." << endl;
|
||||
passTime();
|
||||
displayPetBehavior();
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: run() *
|
||||
* Abstract: Called by MAIN. Starts the program. If the menu loop has exited *
|
||||
* assume the pet is dead and call killed pet. Ask the user if they *
|
||||
* would like to play again. Exit if the user says no. *
|
||||
*****************************************************************************/
|
||||
void Pet::run()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
menu();
|
||||
killedPet();
|
||||
cout << "Would you like to play again?" << endl << ":[Y/n]";
|
||||
char choice;
|
||||
cin >> choice;
|
||||
if (choice == 'n' || choice == 'N')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: KilledPet() *
|
||||
* Abstract: Displays the final statisitcs for the pet. If the boredom level *
|
||||
* or the hunger level are over 21, assume the pet died of boredom *
|
||||
* or hunger. Calls petmood, getboredomlevel, gethungerlevel. *
|
||||
*****************************************************************************/
|
||||
void Pet::killedPet()
|
||||
{
|
||||
cout << "You have killed your pet" << endl << "Your pets' final statistics were: " << endl;
|
||||
cout << " Boredom: " << getBoredomLevel() << endl;
|
||||
cout << " Hunger: " << getHungerLevel() << endl;
|
||||
petMood();
|
||||
if (getBoredomLevel() <= 21)
|
||||
{
|
||||
cout << "Your pet died of boredom." << endl;
|
||||
}
|
||||
else if(getHungerLevel() <= 21)
|
||||
{
|
||||
cout << "Your pet died of hunger." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: cls() *
|
||||
* Abstract: Clears the screen. Buggy. Not used. Here for historical reasons. *
|
||||
*****************************************************************************/
|
||||
void Pet::cls()
|
||||
{
|
||||
cout << endl << endl << endl << endl << endl << endl << endl;
|
||||
cout << endl << endl << endl << endl << endl << endl << endl;
|
||||
cout << endl << endl << endl << endl << endl << endl << endl;
|
||||
cout << endl << endl << endl << endl << endl;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************
|
||||
* Author: Amrit Panesar ,o/ ASP *
|
||||
* Date: 06-19-2013 *
|
||||
* Program: PetSimulator *
|
||||
* File: pet.h *
|
||||
* Function: Holds the member variables and protypes for the Pet class. *
|
||||
* Abstract: This file contains all necessary function prototypes and member *
|
||||
* variables related to the Pet class as defined below. Includes *
|
||||
* iostream for user input and output, string for string usage, *
|
||||
* and ctime for seeding the random function used in Pet.cpp *
|
||||
* Liscence: Released as Public Domain material. *
|
||||
****************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Pet
|
||||
{
|
||||
private:
|
||||
string name;
|
||||
int hungerLevel;
|
||||
int boredomLevel;
|
||||
|
||||
int petMood();
|
||||
void passTime(int time = 1);
|
||||
|
||||
public:
|
||||
Pet (string name, int hunger = 0, int boredom = 0);
|
||||
void setName(string in);
|
||||
string getName();
|
||||
|
||||
void setHungerLevel(int in);
|
||||
int getHungerLevel();
|
||||
|
||||
void setBoredomLevel(int in);
|
||||
int getBoredomLevel();
|
||||
|
||||
void run();
|
||||
void menu();
|
||||
void talk();
|
||||
void play(int play = 1);
|
||||
void feedPet(int food = 1);
|
||||
void displayPetBehavior();
|
||||
|
||||
void killedPet();
|
||||
void cls();
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PetSim", "PetSim\PetSim.vcxproj", "{9F9562DC-A7D1-476E-9097-00EED1220EF6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9F9562DC-A7D1-476E-9097-00EED1220EF6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9F9562DC-A7D1-476E-9097-00EED1220EF6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9F9562DC-A7D1-476E-9097-00EED1220EF6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9F9562DC-A7D1-476E-9097-00EED1220EF6}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,297 @@
|
||||
/*****************************************************************************
|
||||
* Author: Amrit Panesar ,o/ ASP *
|
||||
* Date: 06-19-2013 *
|
||||
* Program: PetSimulator *
|
||||
* File: pet.cpp *
|
||||
* Function: Holds all functions pertaining to the pet class. *
|
||||
* Abstract: This file contains all necessary functions related to the Pet *
|
||||
* class as contained in the Pet.h header file. These functions *
|
||||
* were dictated as such in the project specifications. *
|
||||
* Liscence: Released as Public Domain material. *
|
||||
****************************************************************************/
|
||||
|
||||
#include "Pet.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Constructor - Pet(string, int, int) *
|
||||
* Abstract: Instantiates object. Three parameters are taken, name, hunger, *
|
||||
* and boredom. The constructor also prints the initial statistics *
|
||||
* of the pet. *
|
||||
*****************************************************************************/
|
||||
Pet::Pet (string name, int hunger, int boredom)
|
||||
{
|
||||
setName(name);
|
||||
setHungerLevel(0);
|
||||
setBoredomLevel(0);
|
||||
|
||||
displayPetBehavior();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Setter - setName(string) *
|
||||
* Abstract: Sets the name of the pet. *
|
||||
*****************************************************************************/
|
||||
void Pet::setName(string in)
|
||||
{
|
||||
name = in;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Getter - getName() *
|
||||
* Abstract: Gets the name of the pet. *
|
||||
*****************************************************************************/
|
||||
string Pet::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Setter - setBoredomLevel(int) *
|
||||
* Abstract: Sets the boredom level of the pet if the level is *
|
||||
* between 0 and 100 *
|
||||
*****************************************************************************/
|
||||
void Pet::setBoredomLevel(int in)
|
||||
{
|
||||
if (in >= 0 || in <= 100)
|
||||
boredomLevel = in;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Getter - getBoredomLevel() *
|
||||
* Abstract: Gets the boredom level of the pet. *
|
||||
*****************************************************************************/
|
||||
int Pet::getBoredomLevel()
|
||||
{
|
||||
return boredomLevel;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Setter - setHungerLevel(int) *
|
||||
* Abstract: Sets the hunger level of the pet if the level is *
|
||||
* between 0 and 100 *
|
||||
*****************************************************************************/
|
||||
void Pet::setHungerLevel(int in)
|
||||
{
|
||||
if (in >= 0 || in <= 100)
|
||||
hungerLevel = in;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Getter - getHungerLevel() *
|
||||
* Abstract: Gets the hunger level of the pet. *
|
||||
*****************************************************************************/
|
||||
int Pet::getHungerLevel()
|
||||
{
|
||||
return hungerLevel;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Menu *
|
||||
* Abstract: Does the thing. This is the main interface of the program. *
|
||||
* An enum is used to switch functionality for the interface. *
|
||||
* cin is used to gather input from the user. This function loops *
|
||||
* and calls getName, talk, feedpet and play. A GOTO is used as a *
|
||||
* means to exit from the while loop. This is a standard. *
|
||||
*****************************************************************************/
|
||||
void Pet::menu()
|
||||
{
|
||||
enum { TALK = 1, FEED, PLAY, QUIT };
|
||||
while (true)
|
||||
{
|
||||
cout << "Pet: " << getName() << endl;
|
||||
cout << TALK << ". Talk with your pet." << endl;
|
||||
cout << FEED << ". Feed your pet." << endl;
|
||||
cout << PLAY << ". Play with your pet." << endl;
|
||||
cout << QUIT << ". Quit your pet." << endl;
|
||||
cout << "What would you like to do?" << endl << ":";
|
||||
int menuSelection;
|
||||
cin >> menuSelection;
|
||||
//cls();
|
||||
switch (menuSelection)
|
||||
{
|
||||
case TALK:
|
||||
talk();
|
||||
break;
|
||||
case FEED:
|
||||
feedPet((((rand()%509)*(rand()%349))%4));
|
||||
break;
|
||||
case PLAY:
|
||||
play((((rand()%509)*(rand()%349))%4));
|
||||
break;
|
||||
case QUIT:
|
||||
goto qOut;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
qOut:;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: FeedPet(int) *
|
||||
* Abstract: Feeds the pet. By default it will decrease the hungerlevel by *
|
||||
* one. If the food parameter is less-than or equal to 0 the *
|
||||
* food parameter becomes one. If the food parameter is greater *
|
||||
* than four, the food parameter becomes four. If the hunger level *
|
||||
* is less-than the food parameter, the hunger parameter is set to 0*
|
||||
*****************************************************************************/
|
||||
void Pet::feedPet(int food)
|
||||
{
|
||||
if (food > 4)
|
||||
food = 4;
|
||||
if (food <= 0)
|
||||
food = 1;
|
||||
|
||||
if (getHungerLevel() < food)
|
||||
setHungerLevel(getHungerLevel()-getHungerLevel());
|
||||
else
|
||||
setHungerLevel(getHungerLevel()-food);
|
||||
|
||||
cout << getName() << " has been fed " << food << " pellets of food" << endl;
|
||||
passTime();
|
||||
displayPetBehavior();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: petmood() *
|
||||
* Abstract: Returns the boredomlevel + the hungerlevel of the pet. *
|
||||
*****************************************************************************/
|
||||
int Pet::petMood()
|
||||
{
|
||||
return getBoredomLevel() + getHungerLevel();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: passtime(int = 1) *
|
||||
* Abstract: Increases the hungerlevel and boredom level by the time param *
|
||||
*****************************************************************************/
|
||||
void Pet::passTime(int time)
|
||||
{
|
||||
setHungerLevel(getHungerLevel()+time);
|
||||
setBoredomLevel(getBoredomLevel()+time);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: displaypetbehavior() *
|
||||
* Abstract: Displays the statistics of the pet. This function will also *
|
||||
* display customized messages depending on the hunger and boredom *
|
||||
* levels of the pet. If the levels are less than 3, the pet is *
|
||||
* content. If the levels are between 3 and 11 the pet is a litle <>*
|
||||
* if the levels are greater than 11, the pet is very <>. *
|
||||
*****************************************************************************/
|
||||
void Pet::displayPetBehavior()
|
||||
{
|
||||
cout << " Boredom: " << getBoredomLevel() << endl;
|
||||
cout << " Hunger: " << getHungerLevel() << endl;
|
||||
if (getBoredomLevel() < 3 && getHungerLevel() < 3)
|
||||
cout << getName() << " is content" << endl;
|
||||
|
||||
if ( getBoredomLevel() >= 3 && getBoredomLevel() < 11)
|
||||
cout << getName() << " is a litte bored" << endl;
|
||||
else if (getBoredomLevel() >= 11)
|
||||
cout << getName() << " is very bored" << endl;
|
||||
|
||||
if ( getHungerLevel() >= 3 && getHungerLevel() < 11)
|
||||
cout << getName() << " is a litte hungry" << endl;
|
||||
else if (getHungerLevel() >= 11)
|
||||
cout << getName() << " is very hungry" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: talk() *
|
||||
* Abstract: Displays the 'mood' of the pet. This function displays customized*
|
||||
* messages to the user depending on the return value of the petmood*
|
||||
* function. If the petmood is less than 7, the pet is feeling happy*
|
||||
* If the pet mood is between 6 and 16 then the pet is feeling okay *
|
||||
* If the pet mood is greater than 21 then the pet is feeling bad *
|
||||
*****************************************************************************/
|
||||
void Pet::talk()
|
||||
{
|
||||
if (petMood() < 7)
|
||||
cout << getName() << " is feeling happy!" << endl;
|
||||
else if (petMood() >= 7 && petMood() < 16)
|
||||
cout << "\t" << getName() << " is feeling okay." << endl;
|
||||
else if (petMood() >=16 && petMood() < 21)
|
||||
cout << "\t" << getName() << " is feeling fustrated." << endl;
|
||||
else
|
||||
cout << "\t" << getName() << " is feeling mad!" << endl;
|
||||
passTime();
|
||||
displayPetBehavior();
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: play(int = 0) *
|
||||
* Abstract: Plays with the pet. by default it will decreade the hungerlevel *
|
||||
* by one. If the play parameter is lessthan or equalto 0 the play *
|
||||
* parameter becomes one. If the play parameter is greaterthan four *
|
||||
* then the play parameter becomes four. If the boredom level is *
|
||||
* lessthan the play parameter, the boredom parameter is set to zero*
|
||||
*****************************************************************************/
|
||||
void Pet::play(int play)
|
||||
{
|
||||
if (play > 4)
|
||||
play = 4;
|
||||
if (play <= 0)
|
||||
play = 1;
|
||||
if (getBoredomLevel() < play)
|
||||
setBoredomLevel(getBoredomLevel()-getBoredomLevel());
|
||||
else
|
||||
setBoredomLevel(getBoredomLevel()-play);
|
||||
cout << getName() << " had " << play << " hours of fun." << endl;
|
||||
passTime();
|
||||
displayPetBehavior();
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: run() *
|
||||
* Abstract: Called by MAIN. Starts the program. If the menu loop has exited *
|
||||
* assume the pet is dead and call killed pet. Ask the user if they *
|
||||
* would like to play again. Exit if the user says no. *
|
||||
*****************************************************************************/
|
||||
void Pet::run()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
menu();
|
||||
killedPet();
|
||||
cout << "Would you like to play again?" << endl << ":[Y/n]";
|
||||
char choice;
|
||||
cin >> choice;
|
||||
if (choice == 'n' || choice == 'N')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: KilledPet() *
|
||||
* Abstract: Displays the final statisitcs for the pet. If the boredom level *
|
||||
* or the hunger level are over 21, assume the pet died of boredom *
|
||||
* or hunger. Calls petmood, getboredomlevel, gethungerlevel. *
|
||||
*****************************************************************************/
|
||||
void Pet::killedPet()
|
||||
{
|
||||
cout << "You have killed your pet" << endl << "Your pets' final statistics were: " << endl;
|
||||
cout << " Boredom: " << getBoredomLevel() << endl;
|
||||
cout << " Hunger: " << getHungerLevel() << endl;
|
||||
petMood();
|
||||
if (getBoredomLevel() <= 21)
|
||||
cout << "Your pet died of boredom." << endl;
|
||||
else if(getHungerLevel() <= 21)
|
||||
cout << "Your pet died of hunger." << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: cls() *
|
||||
* Abstract: Clears the screen. Buggy. Not used. Here for historical reasons. *
|
||||
*****************************************************************************/
|
||||
void Pet::cls()
|
||||
{
|
||||
cout << endl << endl << endl << endl << endl << endl << endl;
|
||||
cout << endl << endl << endl << endl << endl << endl << endl;
|
||||
cout << endl << endl << endl << endl << endl << endl << endl;
|
||||
cout << endl << endl << endl << endl << endl;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************
|
||||
* Author: Amrit Panesar ,o/ ASP *
|
||||
* Date: 06-19-2013 *
|
||||
* Program: PetSimulator *
|
||||
* File: pet.h *
|
||||
* Function: Holds the member variables and protypes for the Pet class. *
|
||||
* Abstract: This file contains all necessary function prototypes and member *
|
||||
* variables related to the Pet class as defined below. Includes *
|
||||
* iostream for user input and output, string for string usage, *
|
||||
* and ctime for seeding the random function used in Pet.cpp *
|
||||
* Liscence: Released as Public Domain material. *
|
||||
****************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Pet
|
||||
{
|
||||
private:
|
||||
string name;
|
||||
int hungerLevel;
|
||||
int boredomLevel;
|
||||
|
||||
int petMood();
|
||||
void passTime(int time = 1);
|
||||
|
||||
public:
|
||||
Pet (string name, int hunger = 0, int boredom = 0);
|
||||
void setName(string in);
|
||||
string getName();
|
||||
|
||||
void setHungerLevel(int in);
|
||||
int getHungerLevel();
|
||||
|
||||
void setBoredomLevel(int in);
|
||||
int getBoredomLevel();
|
||||
|
||||
void run();
|
||||
void menu();
|
||||
void talk();
|
||||
void play(int play = 1);
|
||||
void feedPet(int food = 1);
|
||||
void displayPetBehavior();
|
||||
|
||||
void killedPet();
|
||||
void cls();
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9F9562DC-A7D1-476E-9097-00EED1220EF6}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>PetSim</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Pet.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Pet.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Pet.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Pet.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************
|
||||
* Author: Amrit Panesar ,o/ ASP *
|
||||
* Date: 06-19-2013 *
|
||||
* Program: PetSimulator *
|
||||
* File: main.cpp *
|
||||
* Function: MAIN *
|
||||
* Abstract: This file contains the main function which drives the app. *
|
||||
* contained in this file is the means of getting the initial value*
|
||||
* for the name field of the Pet class. This is contained in the *
|
||||
* while loop as seen below. *
|
||||
* Liscence: Released as Public Domain material. *
|
||||
****************************************************************************/
|
||||
|
||||
#include "Pet.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Function: int main(string[], int) *
|
||||
* Abstract: Drives the PetSimulator. Gets the initial value for the pet name *
|
||||
* from the user. This is contained in a loop so that if the user *
|
||||
* makes a mistake on the name for their pet, the user may correct *
|
||||
* their mistake without having to relaunch the program. *
|
||||
*****************************************************************************/
|
||||
int main()
|
||||
{
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
cout << "Welcome to Pet Simulator 2013 Console Edition" << endl << endl;
|
||||
cout << "To begin, we need a name for your pet" << endl;
|
||||
string petname = "";
|
||||
|
||||
//this loop allows the user to confirm and correct a mistake on their pet's name
|
||||
while (true)
|
||||
{
|
||||
cout << "What would you like your pet to be named?" << endl << ":";
|
||||
string in;
|
||||
cin >> in;
|
||||
cout << "You want to name your pet " << in << ". Is that correct?" << endl << ":[Y/n]";
|
||||
char choice;
|
||||
cin >> choice;
|
||||
petname = in;
|
||||
if (choice == 'Y' || choice == 'y')
|
||||
break;
|
||||
}
|
||||
Pet thisPet(petname, 100, 0);
|
||||
thisPet.run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user