#include <iostream>
#include <cstdlib>
using namespace std;
// Farm Game
void cName()
{
string name;
int clrscrl;
naughty:
cout << "Enter a name: ";
cin >> name;
cout << "You have named your critter: " << "> " << name << " <" << "\n\n";
cout << "Do you want to clear the screen? \n\nPress 1 - Clear. \nPress 2 - Dont Clear\n";
cout << "\nChoice: ";
cin >> clrscrl;
switch (clrscrl)
{
case 1:
{
cout << "Clearing screen.";
_sleep(3000);
system("cls");
return;
}
case 2:
{
cout << "Not clearing.\n\n";
_sleep(2000);
return;
}
}
}
int cPlay(int &play)
{
cout << "Critter's Hunger level has increased by 1\n";
++play;
cout << "Hunger level: " << play << "\n";
if (play == 0)
{
cout << "You critter has had a heart attack...\n\nit is DEAD!\n\nExiting...\n\n";
exit(1);
}
if (play == 1)
{
cout << "Your crit is fullup. Dont feed it anymore!\n\n";
}
if (play == 2)
{
cout << "Your crit feels fine now.\n\n";
}
if (play == 3)
{
cout << "your crit is okay.\n\n";
}
if (play == 4)
{
cout << "your crit wants a tiny bit more food - but not too much.\n\n";
}
if (play == 5)
{
cout << "your crit is 50/50 with hunger.\n";
}
if (play == 6)
{
cout << "Your crit says that it will be quite hungry if you \ncontinue playing with it\n\n";
}
if (play == 7)
{
cout << "Your crit wants to eat some food.\n";
}
if (play ==
{
cout << "Your crit is hungry\n";
}
if (play == 9)
{
cout << "Your crit is showing signs of headaches and sickness\nGive it some food\n";
}
if (play == 10)
{
cout << "Your crit has collapsed, and has gone cold...\nSorry its DEAD!";
exit(1);
}
}
int cHunger(int &hunger)
{
cout << "Critter's Hunger level has decreased by 1\n\n";
--hunger;
cout << "Hunger level: " << hunger << "\n";
if (hunger == 0)
{
cout << "You critter has had a heart attack...\n\nit is DEAD!\n\nExiting...\n\n";
exit(1);
}
if (hunger == 1)
{
cout << "Your crit is fullup. Dont feed it anymore!\n\n";
}
if (hunger == 2)
{
cout << "Your crit feels fine now.\n\n";
}
if (hunger == 3)
{
cout << "your crit is okay.\n\n";
}
if (hunger == 4)
{
cout << "your crit wants a tiny bit more food - but not too much.\n\n";
}
if (hunger == 5)
{
cout << "your crit is 50/50 with hunger.\n";
}
if (hunger == 6)
{
cout << "Your crit says that it will be quite hungry if you \ncontinue playing with it\n\n";
}
if (hunger == 7)
{
cout << "Your crit wants to eat some food.\n";
}
if (hunger ==
{
cout << "Your crit is hungry\n";
}
if (hunger == 9)
{
cout << "Your crit is showing signs of headaches and sickness\nGive it some food\n";
}
if (hunger == 10)
{
cout << "Your crit has collapsed, and has gone cold...\nSorry its DEAD!";
exit(1);
}
}
int main()
{
int select;
cout << "Welcome to Girby's Farm. Select one of the following:\n\n";
tryagain:
cout << "Grow a Critter: Press 1\n\n";
cout << "Choice: ";
cin >> select;
switch (select)
{
case 1:
{
cout << "You have grown a Critter: Choose a name for it.\n\n";
cName();
break;
}
default:
cout << "Sorry but you have chosen an incorrect choice - try again\n\n";
goto tryagain;
}
int select2;
int cHungerLev = 5;
cLife:
cout << "What would you like to do with your new critter?\n\n";
cout << "Feed: Press 1\n";
cout << "Play: Press 2\n";
cout << "Check Hunger Level: Press 3\n";
cout << "Clear Screen: Press 4\n\n";
cout << "Choice: ";
cin >> select2;
system("cls");
if (select2 == 1)
{
cHunger(cHungerLev);
}
if (select2 == 2)
{
cPlay(cHungerLev);
}
if (select2 == 3)
{
cout <<"Hunger Level = " << cHungerLev << "\n";
}
if (select2 == 4)
{
cout << "Clearing Screen.";
_sleep(3000);
system("cls");
}
goto cLife;
return 0;
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.