Archives from S:\ Drive

Good to keep around methinks
This commit is contained in:
Amrit Panesar committed 2015-04-01 21:23:15 -07:00
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 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PetSim", "PetSim\PetSim.vcxproj", "{8387506E-641F-4005-AF63-F98EBDDF0E48}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8387506E-641F-4005-AF63-F98EBDDF0E48}.Debug|Win32.ActiveCfg = Debug|Win32
{8387506E-641F-4005-AF63-F98EBDDF0E48}.Debug|Win32.Build.0 = Debug|Win32
{8387506E-641F-4005-AF63-F98EBDDF0E48}.Release|Win32.ActiveCfg = Release|Win32
{8387506E-641F-4005-AF63-F98EBDDF0E48}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,21 @@
#include "stdhead.h"
using namespace std;
class CenteredOut
{
public:
ostream &m_file;
CenteredOut(ostream &o = cout):m_file(o){};
template <typename T>
CenteredOut &operator<<(const T &a) {
m_file<<a;
return *this;
}
CenteredOut &operator<<(ostream& (*pf) (ostream&)){
m_file<<pf;
return *this;
}
};
@@ -0,0 +1,158 @@
/******************************************************************************
* Pet.cpp - Define a pet object *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Date: 08/18/2014 *
* License: Released into public domain *
*****************************************************************************/
#include "stdhead.h"
/****************************************** Getters and Setters **************/
int Pet::getHungerLevel()
{
return hungerlevel;
}
void Pet::setHungerLevel(int hunger)
{
hungerlevel = hunger;
}
int Pet::getBoredomLevel()
{
return boredomlevel;
}
void Pet::setBoredomLevel(int boredom)
{
boredomlevel = boredom;
}
string Pet::getName()
{
return name;
}
void Pet::setName(string name)
{
Pet::name = name;
}
/*********************** lets begin ******************************************/
Pet::Pet(string name, int hunger, int boredom)
{
setName(name);
setHungerLevel(hunger);
setBoredomLevel(boredom);
}
void Pet::Talk()
{
if (PetMood() < 7)
cout << getName() << " is feeling happy!" << endl;
else if (PetMood() >= 7 && PetMood() < 16)
cout << getName() << " is feeling okay." << endl;
else if (PetMood() >=16 && PetMood() < 21)
cout << getName() << " is feeling fustrated." << endl;
else
cout << getName() << " is feeling mad!" << endl;
PassTime();
DisplayPetBehavior();
}
void Pet::FeedPet(int in)
{
if (in > 4)
in = 4;
if (in <= 0)
in = 1;
if (getHungerLevel() < in)
setHungerLevel(getHungerLevel()-getHungerLevel());
else
setHungerLevel(getHungerLevel()-in);
cout << getName() << " has been fed " << in << " pellets of food" << endl;
PassTime();
DisplayPetBehavior();
}
void Pet::Play(int in)
{
if (in > 4)
in = 4;
if (in <= 0)
in = 1;
if (getBoredomLevel() < in)
setBoredomLevel(getBoredomLevel()-getBoredomLevel());
else
setBoredomLevel(getBoredomLevel()-in);
cout << getName() << " had " << in << " hours of fun." << endl;
PassTime();
DisplayPetBehavior();
}
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;
}
int Pet::PetMood()
{
return getBoredomLevel() + getHungerLevel();
}
void Pet::PassTime(int time)
{
setHungerLevel(getHungerLevel()+time);
setBoredomLevel(getBoredomLevel()+time);
}
void Pet::menu()
{
enum { TALK = 1, FEED, PLAY, QUIT };
bool breakout = false;
while (!breakout)
{
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 = getch() - '0';
//cls();
system("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:
breakout = true;
default:
break;
}
}
}
@@ -0,0 +1,39 @@
/******************************************************************************
* Pet.h - Define a pet object *
* Author: Amrit Panesar <apanesar@coleman.edu> *
* Date: 08/18/2014 *
* License: Released into public domain *
*****************************************************************************/
#include "stdhead.h"
class Pet
{
private:
int hungerlevel;
int boredomlevel;
string name;
int PetMood();
void PassTime(int time = 1);
int getHungerLevel();
void setHungerLevel(int hunger);
int getBoredomLevel();
void setBoredomLevel(int boredom);
string getName();
void setName(string name);
public:
Pet(string name, int hunger = 0, int boredom = 0);
void Talk();
void FeedPet(int in);
void Play(int in);
void DisplayPetBehavior();
void menu();
};
@@ -0,0 +1,173 @@
// PetSim.cpp : Defines the entry point for the console application.
//
#include "stdhead.h"
bool yorn();
void ChangeIcon( const HICON hNewIcon );
int _tmain(int argc, _TCHAR* argv[])
{
int i;
time_t t = time(NULL);
tm* timePtr = localtime(&t);
TCHAR szNewTitle[MAX_PATH];
HMODULE hMainMod = GetModuleHandle( 0 );
assert( hMainMod );
HICON hMainIcon = ::LoadIcon( hMainMod, MAKEINTRESOURCE( IDI_ICON1 ));
assert( hMainIcon );
// Change main window icon
ChangeIcon( hMainIcon );
system("color 1e");
StringCchPrintf(szNewTitle, MAX_PATH, TEXT("Pet Simulator %d"), timePtr->tm_year + 1900);
SetConsoleTitle(szNewTitle);
cout << string(80, '*');
cout << "Welcome to Pet Simulator " << timePtr->tm_year + 1900 << " Edition!" << endl << endl;
cout << string(80, '*');
bool named = false;
string name;
while(!named)
{
cout << endl << endl;
cout << "Step one: Name your pet." << endl;
cout << "It's time to name your pet! Please enter a name for your pet" << endl << ": ";
cin >> name;
cout << "You've named your pet: " << name << endl << endl;
cout << "Is this correct?" << endl << "[Y/n]: ";
i = getch();
cout << (char)i << endl;
bool breakout = false;
if ( i == 89 || 121 || 13 || 27 || 28 || 110)
{
switch (i)
{
case 89:
case 121:
case 13:
named = true;
breakout = true;
break;
case 27:
case 28:
case 110:
breakout = true;
break;
}
}
if (!breakout)
{
if (yorn())
{
named = true;
breakout = true;
}
else
{
breakout = true;
}
}
}
Pet pet = Pet(name);
bool breakout = false;
while(!breakout)
{
pet.menu();
system("cls");
cout << "Would you like to play again?" << endl << "[Y/n]: ";
i = getch();
cout << (char)i << endl;
bool bjorn = false;
if ( i == 89 || 121 || 13 || 27 || 28 || 110)
{
switch (i)
{
case 89:
case 121:
case 13:
bjorn = true;
breakout = false;
break;
case 27:
case 28:
case 110:
bjorn = true;
breakout = true;
break;
default:
bjorn = false;
}
}
if (!bjorn)
{
if (yorn())
{
breakout = false;
}
else
{
breakout = true;
}
}
}
system("cls");
cout << "Game over .." << endl << endl;
cout << "Press any key to continue...";
getch();
return 0;
}
bool yorn()
{
int i = 0;
while (i != 0)
{
cout << "Please enter Y or N :" << endl;
i = getch();
cout << (char)i << endl;
switch (i)
{
case 89:
case 121:
return true;
break;
case 28:
case 110:
return false;
break;
default:
i = 0;
}
}
ChangeIcon( 0 );
}
void ChangeIcon( const HICON hNewIcon )
{
// Load kernel 32 library
HMODULE hMod = LoadLibrary( _T( "Kernel32.dll" ));
assert( hMod );
// Load console icon changing procedure
typedef DWORD ( __stdcall *SCI )( HICON );
SCI pfnSetConsoleIcon = reinterpret_cast<SCI>( GetProcAddress( hMod, "SetConsoleIcon" ));
assert( pfnSetConsoleIcon );
// Call function to change icon
pfnSetConsoleIcon( hNewIcon );
FreeLibrary( hMod );
}// End ChangeIcon
@@ -0,0 +1,98 @@
<?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>{8387506E-641F-4005-AF63-F98EBDDF0E48}</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>NotUsing</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>Use</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>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CenteredOut.h" />
<ClInclude Include="Pet.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdhead.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Pet.cpp" />
<ClCompile Include="PetSim.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,52 @@
<?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>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Pet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CenteredOut.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdhead.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="PetSim.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Pet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="icon.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>
@@ -0,0 +1,40 @@
========================================================================
CONSOLE APPLICATION : PetSim Project Overview
========================================================================
AppWizard has created this PetSim application for you.
This file contains a summary of what you will find in each of the files that
make up your PetSim application.
PetSim.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
PetSim.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
PetSim.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named PetSim.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

@@ -0,0 +1,29 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
using namespace std;
#include <stdio.h>
#include <iostream>
#include <string>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <windows.h>
#include <tchar.h>
#include <conio.h>
#include <strsafe.h>
// TODO: reference additional headers your program requires here
#include "CenteredOut.h"
#include "resource.h"
#include "Pet.h"