Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Bazoonkas_Tamagotchi/LifeandDeath.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76 lines (72 sloc)
1.72 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <fstream> | |
#include "display.h" | |
#include <vector> | |
#include "AnimalStates.h" | |
#include "time.h" | |
using namespace std; | |
std::string egghatching() | |
{ | |
ifstream f("eggs.txt"); | |
if (f.is_open()) | |
cout << f.rdbuf(); | |
cout << "You stumble over a pile of eggs. You feel a need to pick one up" << endl; | |
system("pause"); | |
std::string option1= "Pick one up carefully"; | |
std::string option2= "Watch what happens"; | |
vector<string> options={"Pick one up carefully","Watch what happens"}; | |
string output = Display(options); | |
system("cls"); | |
ifstream g("eggstate.txt"); | |
if (g.is_open()) | |
cout << g.rdbuf(); | |
cout << "An extremely delicate egg lies in front of you"<< endl; | |
system("pause"); | |
int click = 0; | |
while( click < 11) | |
{ | |
system("cls"); | |
ifstream l("eggstate1.txt"); | |
if (l.is_open()) | |
cout << l.rdbuf(); | |
Sleep(500); | |
system("cls"); | |
ifstream m("eggstate2.txt"); | |
if (m.is_open()) | |
cout << m.rdbuf(); | |
Sleep(500); | |
click= click + 1; | |
} | |
vector<string> hatch={"Its hatching...","Maybe they're just dancing.. "}; | |
string output2 = Display(hatch); | |
vector<string> pet={"Dog","Cat"}; | |
srand(time(0)); | |
int index = rand() % pet.size(); // pick a random index | |
std::string userpet = pet[index]; | |
cout<< "What would you like to name this creature?" << endl; | |
string name; | |
cin >> name; | |
if(userpet == "Cat") | |
{ | |
Cat e(name); | |
e.normal(); | |
cout << "\n" << e.getHappy() << endl; | |
cout<< "Congratulations, you are now a parent" << endl; | |
system("pause"); | |
} | |
if(userpet == "Dog") | |
{ | |
Dog e(name); | |
e.normal(); | |
cout << "\n" << e.getHappy() << endl; | |
cout<< "Congratulations, you are now a parent" << endl; | |
system("pause"); | |
} | |
return userpet; | |
} | |
int main() | |
{ | |
egghatching(); | |
return 0; | |
} |