Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

'm making a text based game in c++ and I'm trying to call int mane(int argc, char * const argv[]) into the void trainwithothers. but

'm making a text based game in c++ and I'm trying to call int mane(int argc, char * const argv[]) into the void trainwithothers. but the only way it dose not give me errors is shown below but mane isn't being called because of the int and when i change int mane(int argc, char * const argv[]) to int main(int argc, char * const argv[]) it will run but in front of all my other code and then close once its done. Is there another way to call it without me having to over wright my already exesting main? would a pionter work? (I have provided all the code like i was told my one of the experts)

#include

#include

#include

#include

#include

#include

#include

#include

#include "MOnsta.h"

#include "main.h"

#include "Character.h"

#include "Training.h"

using namespace std;

void SaveGame();

void shush();

#define MAX_LENGTH 100

char ch;

char WTDpark;

char ver;

char filename[50];

char pName[MAX_LENGTH] = { 0 };

char mName[MAX_LENGTH] = { 0 };

int entreynum = 78;

int mClasschoice;

int counter = 0;

ofstream save;

string mClass;

string arr[100];

string name;

int health;

int socialconstructoftradevaluesandfemaledogs = 100;

Character intobattle()

{

string n;

int range = 1, attackBonus = 2, swish = 5, health = 100, mp = 10, choice;

cout << "What is your name?" << endl;

cin >> n;

cout << "Your current stats are, attackBonus: " << attackBonus << " arrows: " << swish << " mp: " << mp;

cout << " health: " << health << " range: " << range << endl;

cout << "you have 5 tokens which you can spend on increasing your Character's statistics. You can"

<< "spend 1 for 1 attack-bonus, 3 arrows, 4 mp, or 10 health. You can also spend 2 to get 3 range" << endl;

cout << "Choose 1 for attack bonus, 2 for arrows, 3 for mp, 4 for health, and 5 for range." << endl;

for (int tokens = 5; tokens>0; tokens--)

{

cout << "tokens: " << tokens << endl;

cin >> choice;

switch (choice)

{

case 1:

attackBonus++;

cout << "Attack Bonus: " << attackBonus << endl;

break;

case 2:

swish += 3;

cout << "Special Attack: " << swish << endl;

break;

case 3:

mp += 4;

cout << "mp: " << mp << endl;

break;

case 4:

health += 10;

cout << "health: " << health << endl;

break;

case 5:

if (tokens>2)

{

tokens--;

range += 3;

cout << "range: " << range << endl;

}

else

{

cout << "Not enough tokens!" << endl;

tokens++;

}

break;

default:

cout << "Please choose a number from 1 to 5" << endl;

break;

}

}

cout << "Congratulations, you may now set forth into the world, young adventurer." << endl;

return Character(n, attackBonus, swish, mp, health, range);

}

MOnsta Jim("Jim", 50, 2, 1);

int train(int argc, char * const argv[])

{

Character C = intobattle();

training training(Jim);

training.training1(C);

}

void trainwithothers()

{

cout << "You decide to train with the others in the park" << endl;

int train(int argc, char * const argv[])

}

int putInBag()

{

while (1)

{

if (counter == 100)

break;

cout << "would you like to add item to your backpack? y/n" << endl;

cin >> ch;

if (ch == 'y' || ch == 'Y')

{

cout << "Enter name of object as it appears to add it to your backpack." << endl;

cin >> name;

arr[counter] = name;

counter++;

cout << endl;

cout << "Items in backpack:" << endl;

for (int i = 0;i < counter;i++)

cout << arr[i] << endl;

break;

}

else if (ch == 'n' || ch == 'N')

{

break;

}

else

{

cout << "please select a proper choice" << endl;

}

system("pause");

}

return 0;

}

void webpage()

{

system("pause");

system("cls");

do

{

system("color 0fc");

cin.ignore();

cout << "\t Pet Registration" << endl;

cout << "Hello and please enter your name: ";

cin.getline(pName,MAX_LENGTH);

cout << " Please enter your pets name: ";

cin.getline(mName,MAX_LENGTH);

cout << " Please select your pets class. " << endl;

cout << "1) Fire" << endl;

cout << "2) Water" << endl;

cout << "3) Grass " << endl;

cin >> mClasschoice;

if (mClasschoice == 1)

{

mClass = "fire";

}

else if (mClasschoice == 2)

{

mClass = "water";

}

else if (mClasschoice == 3)

{

mClass = "Grass";

}

else

{

cout << "Error please try again" << endl;

mClass = "ERROR";

}

cout << " Please verify your information. Your name: " << pName << " Pets name: " << mName << " Pets class: " << mClass << endl;

cout << " Is the above information correct? y/n " << endl;

cout << endl;

cin >> ver;

} while (ver != 'y' && 'Y' || mClass == "ERROR");

cout << "Congratulations " << pName << "! you and " << mName << " are now registered as contestants number " << entreynum << "." << endl;

cout << "Please print out your ticket and bring it to the competition. See you soon!!!" << endl;

system("pause");

}

void webpageExit()

{

system("cls");

system("color 07");

cout << "And its done! You walk over to your printer grab your ticket and put in in your bag. " << endl;

putInBag();

cout << endl;

cout << "You hear a soft grumble.You turn around and see " << mName << endl;

cout << "you lean down and pet their soft yet rough " << mClass << "y fur" << endl;

cout << "they grumble in content. You straighten up, sling your bag over your shoulder, bid your mother farewell and head for the door. " << endl;

cout << "You have one foot out the door when you realize you forgot your wallet, you turn around and go to grab it. " << endl;

putInBag();

cout << endl;

cout << "You open your wallet and see that you have $" << socialconstructoftradevaluesandfemaledogs << "." <

cout << "Now with everything you need you and " << mClass << "head out on your adventure!" << endl;

}

void FeedDucks()

{

cout << "You get up and feed the ducks they are unhappy with your sacrifice of bread and attack you." << endl;

health - 10;

}

void park()

{

system("cls");

system("color A0");

cout << "You arrive at the park! You look around and see lots of other people with their pets, doing a lot of last minuet training before the show.";

cout << "You lay down in the grass with " << mName << "to think about what your next movie will be" << endl;

cout << endl;

cout << "################################" << endl;

cout << " " << endl;

cout << " 1 - Go to next area " << endl;

cout << " 2 - Feed the ducks " << endl;

cout << " 3 - Train with others " << endl;

cout << " 4 - Pet " << mName << endl;

cout << " 5 - Go home and cry " << endl;

cout << " " << endl;

cout << "################################" << endl;

cin >> WTDpark;

switch (WTDpark)

{

case 1:

break;

case 2:

break;

case 3:

trainwithothers();

break;

case 5:

break;

}

}

void gameStart()

{

system("cls");

cout << "It's finally the day that you have been waiting for, the day you are going to prove to the world that you have the best pet monster! " << endl;

cout << "But first you must register your monster for the competition. " << endl;

cout << "You go to your computer and bring up the Best Pet registration page. " << endl;

}

void About()

{

system("cls");

cout << "\t About This Game" << endl;

cout << endl;

cout << "Basic Text Virtual Monster Game" << endl;

cout << "Build 0.01" << endl;

cout << "Built For Final Project" << endl;

cout << "Created By Sydney" << endl;

cout << "Created with C++" << endl;

cout << "Copyright 2018" << endl;

cout << "YEET!" << endl;

cout << endl;

system("PAUSE");

}

int main()

{

system("cls");

system("color 07");

cout << " (=)_____________________________________________________________(=) " << endl;

cout << " | Best Pet Quest |" << endl;

cout << " | 1 - Start |" << endl;

cout << " | 2 - Load |" << endl;

cout << " | 3 - About This Game |" << endl;

cout << " | 4 - Quit |" << endl;

cout << " (=)_____________________________________________________________(=)" << endl;

int choice;

cin >> choice;

switch (choice)

{

case 1:

// game goes here

gameStart();

webpage();

webpageExit();

park();

break;

case 2:

// load

break;

case 3:

// about

About();

main();

break;

case 5:

// secret

shush();

main();

break;

}

system("pause");

return (0);

}

void SaveGame()

{

ofstream output_file("SavedGame.text", ios::out | ios::app);

output_file << pName << endl; output_file << pName << endl;

output_file << mClass << endl;

output_file.close();

}

void shush()

{

system("cls");

system("color 39");

cout << " ,/ " << endl;

cout << " // " << endl;

cout << " ,// " << endl;

cout << " ___ /| |// " << endl;

cout << " `__/\\_ --(/|___/-/ " << endl;

cout << " \\|\\_-\\___ __-_`- /-/ \\. " << endl;

cout << " |\\_-___,-\\_____--/_)' ) \\ " << endl;

cout << " \ -_ / __ \\( `( __`\\| " << endl;

cout << " `\__| |\\)\\ ) /(/| " << endl;

cout << " ,._____., ',--//-| \\ | ' / " << endl;

cout << " / __. \\, / /,---| \ / ''Hello, I'm Daniel.''" << endl;

cout << " / / _. \\ \\ `/`_/ _,' | | ''That was a very Luis like thing you did. Dont be like Luis.'' " << endl;

cout << " | | ( ( \\ | ,/\\'__/'/ | | " << endl;

cout << " | \\ \\`--, `_/_------______/ \\( )/ " << endl;

cout << " | | \\ \\_. \\, \\___/\\" << endl;

cout << " | | \\_ \\ \\ \\ "<< endl;

cout << " \\ \\ \\_ \\ \\ / \\ " << endl;

cout << " \\ \\ \\._ \\__ \\_| | \\ " << endl;

cout << " \\ \\___ \\ \\ | \\ " << endl;

cout << " \\__ \\__ \\ \\_ | \\ | " << endl;

cout << " | \\_____ \\ ____ | | " << endl;

cout << " | \\ \\__ ---' .__\\ | | | " << endl;

cout << " \\ \\__ --- / ) | \\ / " << endl;

cout << " \\ \\____/ / ()( \\ `---_ /| " << endl;

cout << " \\__________/(,--__ \\_________. | ./ | " << endl;

cout << " | \\ \\ `---_\\--, \\ \_,./ | " << endl;

cout << " | \\ \\_ ` \\ /`---_______-\\ \\ / " << endl;

cout << " \\ \.___,`| / \\ \\ \\ " << endl;

cout << " \\ | \\_ \\| \\ ( |: | " << endl;

cout << " \\ \\ \\ | / / | ; " << endl;

cout << " \\ \\ \\ \\ ( `_' \\ | " << endl;

cout << " \\. \\ \\. \\ `__/ | | " << endl;

cout << " \\ \\ \\. \\ | | " << endl;

cout << " \\ \\ \\ \\ ( ) " << endl;

cout << " \\ | \\ | | | " << endl;

cout << " | \\ \\ \\ I ` " << endl;

cout << " ( __; ( _; ('-_'; " << endl;

cout << " |___\\ \\___: \\___: " << endl;

Beep(1480, 200);

Beep(1568, 200);

Beep(1568, 200);

Beep(1568, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(369.99, 200);

Beep(392, 200);

Beep(369.99, 200);

Beep(392, 200);

Beep(392, 400);

Beep(196, 400);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(880, 200);

Beep(830.61, 200);

Beep(880, 200);

Beep(987.77, 400);

Beep(880, 200);

Beep(783.99, 200);

Beep(698.46, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(880, 200);

Beep(830.61, 200);

Beep(880, 200);

Beep(987.77, 400);

Sleep(200);

Beep(1108, 10);

Beep(1174.7, 200);

Beep(1480, 10);

Beep(1568, 200);

Sleep(200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(783.99, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(880, 200);

Beep(830.61, 200);

Beep(880, 200);

Beep(987.77, 400);

Beep(880, 200);

Beep(783.99, 200);

Beep(698.46, 200);

Beep(659.25, 200);

Beep(698.46, 200);

Beep(784, 200);

Beep(880, 400);

Beep(784, 200);

Beep(698.46, 200);

Beep(659.25, 200);

Beep(587.33, 200);

Beep(659.25, 200);

Beep(698.46, 200);

Beep(784, 400);

Beep(698.46, 200);

Beep(659.25, 200);

Beep(587.33, 200);

Beep(523.25, 200);

Beep(587.33, 200);

Beep(659.25, 200);

Beep(698.46, 400);

Beep(659.25, 200);

Beep(587.33, 200);

Beep(493.88, 200);

Beep(523.25, 200);

Sleep(400);

Beep(349.23, 400);

Beep(392, 200);

Beep(329.63, 200);

Beep(523.25, 200);

Beep(493.88, 200);

Beep(466.16, 200);

Beep(440, 200);

Beep(493.88, 200);

Beep(523.25, 200);

Beep(880, 200);

Beep(493.88, 200);

Beep(880, 200);

Beep(1760, 200);

Beep(440, 200);

Beep(392, 200);

Beep(440, 200);

Beep(493.88, 200);

Beep(783.99, 200);

Beep(440, 200);

Beep(783.99, 200);

Beep(1568, 200);

Beep(392, 200);

Beep(349.23, 200);

Beep(392, 200);

Beep(440, 200);

Beep(698.46, 200);

Beep(415.2, 200);

Beep(698.46, 200);

Beep(1396.92, 200);

Beep(349.23, 200);

Beep(329.63, 200);

Beep(311.13, 200);

Beep(329.63, 200);

Beep(659.25, 200);

Beep(698.46, 400);

Beep(783.99, 400);

Beep(440, 200);

Beep(493.88, 200);

Beep(523.25, 200);

Beep(880, 200);

Beep(493.88, 200);

Beep(880, 200);

Beep(1760, 200);

Beep(440, 200);

Beep(392, 200);

Beep(440, 200);

Beep(493.88, 200);

Beep(783.99, 200);

Beep(440, 200);

Beep(783.99, 200);

Beep(1568, 200);

Beep(392, 200);

Beep(349.23, 200);

Beep(392, 200);

Beep(440, 200);

Beep(698.46, 200);

Beep(659.25, 200);

Beep(698.46, 200);

Beep(739.99, 200);

Beep(783.99, 200);

Beep(392, 200);

Beep(392, 200);

Beep(392, 200);

Beep(392, 200);

Beep(196, 200);

Beep(196, 200);

Beep(196, 200);

Beep(185, 200);

Beep(196, 200);

Beep(185, 200);

Beep(196, 200);

Beep(207.65, 200);

Beep(220, 200);

Beep(233.08, 200);

Beep(246.94, 200);

system("pause");

}

----------------------------------------------------

#include "BeingAttacket.h"

#include

void Being::attack(Being& target)

{

int damage = (int)(attackMod*(((rand() % 100)*(range + 1) / 100) + attackBonus));

target.health -= damage;

cout << name << " attacks " << target.name << " doing " << damage << " damage!" << endl;

cout << target.name << "'s health: " << target.health << endl;

}

void Being::SPattack(Being& target)

{

int damage = (int)(attackMod*(((rand() % 100)*(range + 1) / 100)));

if (swish>0)

{

swish--;

int damage = rand() % 8;

if (damage == 0)

{

cout << name << " misses " << target.name;

}

else

{

if (damage == 7)

{

damage = 15;

damage *= attackMod;

target.health -= damage;

cout << name << " shoots " << target.name << " doing " << damage << " damage!" << endl;

cout << target.name << "'s health: " << target.health << endl;

}

}

}

else

cout << name << " is out of special!" << endl;

}

void Being::heal()

{

health = healthMax;

mp = mpMax;

}

------------------------------------

#include "Character.h"

Character::Character(string newname, int newAttackBonus, int newswish, int newMp, int newHealth, int newRange)

{

name = newname;

health = healthMax = newHealth;

mp = mpMax = newMp;

swish = newswish;

attackMod = 1;

attackBonus = newAttackBonus;

range = newRange;

}

void Character::display()

{

cout << name << " health: " << health << " special: " << swish << endl;

}

--------------------------------------

#include "Training.h"

#include "MOnsta.h"

#include "Character.h"

training::training(MOnsta& newM) : M(newM)

{

}

void training::trainingChoice(Character& C)

{

if (C.health>0)

{

C.display();

cout << "What do you do? 1 attack, 2 special attack" << endl;

short choice;

cin >> choice;

switch (choice)

{

case 1:

C.attack(M);

break;

case 2:

C.SPattack(M);

break;

}

}

else

cout << C.name << " is dead!" << endl;

}

void training::training1(Character& C)

{

while (M.health>0 && C.health>0)

{

M.attack(C);

trainingChoice(C);

}

if (M.health<0)

cout << "Congratulations! You Beat the monster!" << endl;

if (C.health<0)

cout << "YOU HAVE FAILED! BATTLE OVER" << endl;;

}

-------------------------------------

#include "MOnsta.h"

MOnsta::MOnsta(string newname, int newHealth, int newAttackBonus, int newRange)

{

name = newname;

health = newHealth;

attackBonus = newAttackBonus;

range = newRange;

attackMod = 1;

swish = 10;

}

-----------------------------------

#ifndef training_h

#define traing_h

#include "MOnsta.h"

#include "Character.h"

#include

class training

{

public:

MOnsta& M;

training(Character& NewM);

training(MOnsta & newM);

void trainingChoice(Character& C);

void training1(Character& C);

};

#endif

------------------------------------

#ifndef main_h #define main_h #include #include

class MOnsta;

class Character;

#endif

---------------------------------

#ifndef Character_h

#define Character_h

#include

#include

#include "MOnsta.h"

#include "main.h"

#include "BeingAttacket.h"

using namespace std;

class Character : public Being

{

public:

Character(string, int, int, int, int, int);

void display();

};

#endif

------------------------------------------

#ifndef main_h #define main_h #include #include

class MOnsta;

class Character;

#endif

-----------------------------

#ifndef training_h

#define traing_h

#include "MOnsta.h"

#include "Character.h"

#include

class training

{

public:

MOnsta& M;

training(Character& NewM);

training(MOnsta & newM);

void trainingChoice(Character& C);

void training1(Character& C);

};

#endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions