Age Of Empire Text.

This is a discussion on Age Of Empire Text. within the Game Programming forums, part of the General Programming Boards category; Hello, finally, after 3 days... i finished it... Thanks to Elysia for helping me so much on classes, concepts, errors, ...

  1. #1
    deletedforumuser
    Guest

    Age Of Empire Text.

    Hello, finally, after 3 days... i finished it... Thanks to Elysia for helping me so much on classes, concepts, errors, helping me learn so much new stuff... Elysia made me finish this. Thanks Elysia.


    Everything is done but the Combat system. I will work on it tommorow. Tommorow it will be done...

    It's not really like Age of Empire, but it's relies to Rts games. It doesn't have all the features and stuff...It's only a text game i made to learn. And i learned so much stuff about it...

    I have worked about 15 hours a day on it...for 3-4 days.

    And, before making this small game...i haven't even thought about it...i just writed some codes..then i continued...continued..and didnt stop adding new stuff.

    Here it is...It's my first big project. Now, i will move on to more advanced c++. Total of 2034 line of codes. Im so happy i finished it.

    Website to download: http://filebeam.com/28c1d0ce0883ae17a0cc8aff7a796170

    Click on the website above to get the source....


    Or, if you wish to copy and paste here's the codes.

    Make sure you use stdafx for the project.


    stdafx.cpp
    Code:
    #include "stdafx.h"
    stdafx.h
    Code:
    #include <iostream>
    #include <windows.h>
    #include <string>
    #include <ctime>
    main.cpp
    Code:
    #include "stdafx.h"
    #include "Army.h"
    #include "Player.h"
    #include "Nation.h"
    #include "VillagerDo.h"
    #include "ArmyDo.h"
    #include "Build.h"
    #include "Show.h"
    #include "Upgrader.h"
    #include "WorkShop.h"
    #include <string>
    #include <iostream>
    #include <windows.h>
    
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    
    int main()
    {
    
    
    
    
    	//Create the nation
    	Nation nation;
    	//Create the player
    	Player player;
    	//Show
    	Show show;
    	//Army
    	Army army;
    	//VillagerDo
    	VillagerDo villagerdo;
    	//ArmyDo
    	ArmyDo armydo;
    	//Build
    	Build build;
    	//Upgrad
    	UpgradDo upgrader;
    	//Workshop
    	Workshop workshop;
    
    
    	//choice if the player decide to accept to be their leader.
    	int choice;
    	//yourname
    	std::string choosename;
    	//yournation name
    	std::string choosenationname;
    
    	cout <<"Hello, we, the villagers, are searching for a new leader."<<endl;
    	cout <<"We are ready to work for you if you accept to be our leader."<<endl;
    	cout <<"Do you want or not?"<<endl;
    	cout <<"1.Yes"<<endl;
    	cout <<"2+.No"<<endl;
    	cout <<">>";
    	cin >> choice;
    
    	//If the user respond no
    	if (choice >= 2)
    	{
    		system("cls");
    		cout <<"Okay, we'll find another leader";
    		Sleep(2000);
    		return 0;
    	}
    
    	//If the user respond yes
    	else if (choice == 1)
    	{
    		system("cls");
    		cout <<"Since you accepted, can we know your name?"<<endl;
    		cout <<">>";
    		cin >> choosename;
    		system("cls");
    		cout <<"Okay "<<player.getName()<<", what name will you give to our nation?"<<endl;
    		cout <<">>";
    		cin >> choosenationname;
    
    		//Set yourname + nationname
    		nation.setName(choosenationname);
    		player.setName(choosename);
    
    		system("cls");
    
    		show.WhatToDo(nation, player, army, villagerdo, armydo, build, upgrader, workshop);
    
    
    
    	}
    
    	cin.get();
    
    	return 0;
    
    }


    Army.cpp

    Code:
    #include "stdafx.h"
    #include "Nation.h"
    #include "Army.h"
    #include <string>
    
    
    //construct
    Army::Army()
    {
    	aArmy = 1;  //Army
    	aAttack = 6; //Army attack
    	aDefense = 2; //Army defense
    	aName = "Noble"; //Army name
    }
    
    //destruct
    Army::~Army()
    {
    
    }
    
    //How much army
    int Army::getArmy() const
    {
    	return aArmy;
    }
    //Set the army
    void Army::setArmy(int army)
    {
    	aArmy = army;
    }
    
    
    
    //Army attack
    int Army::getAttack() const
    {
    	return aAttack;
    }
    //Set the attack
    void Army::setAttack(int armyattack)
    {
    	aAttack = armyattack;
    }
    
    
    //Army defense
    int Army::getDefense() const
    {
    	return aDefense;
    }
    //set the Defense
    void Army::setDefense(int armydefense)
    {
    	aDefense = armydefense;
    }
    
    
    //Army rank name;
    std::string Army::getName() const
    {
    	return aName;
    }
    //Army set Name;
    void Army::setName(std::string armyname)
    {
    	aName = armyname;
    }

    Army.h

    Code:
    //Army class
    #ifndef ARMY_H
    #define ARMY_H
    
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    #include <string>
    
    class Army
    {
    public:
    
    	//Construct
    	Army();
    	//Destruct
    	~Army();
    	//Army
    	int getArmy() const;
    	void setArmy(int army);
    	//Atk
    	int getAttack() const;
    	void setAttack(int armyattack);
    	//Defense
    	int getDefense() const;
    	void setDefense(int armydefense);
    	//army rank
    	std::string getName() const;
    	void setName(std::string armyname);
    
    
    public:
    
    	//Army
    	int aArmy;
    	//Army attack
    	int aAttack;
    	//Army defense
    	int aDefense;
    	//Army name
    	std::string aName;
    
    
    };
    
    #endif // ARMY_H


    ArmyDo.cpp

    Code:
    #include "stdafx.h"
    #include "VillagerDo.h"
    #include "Player.h"
    #include "Nation.h"
    #include "ArmyDo.h"
    #include "Show.h"
    #include "Build.h"
    #include "Army.h"
    #include "WorkShop.h"
    #include <iostream>
    
    using std::cout;
    using std::endl;
    using std::cin;
    
    
    int ArmyDo::aAttack(Nation &nation, const Show &show, const VillagerDo &villagerdo, const Player &player, Army &army, Build build, UpgradDo &upgrader, Workshop workshop) const
    {
    	int attackarmychoice;
    	bool looparmyattack = true;
    
    
    	cout <<"---QUEST---\n\n"<<endl;
    	cout <<"1.Attack 20 Army[Attack: 5 defense: 5]"<<endl;
    	cout <<">>";
    	cin >> attackarmychoice;
    
    	switch (attackarmychoice)
    	{
    
    	case 1:
    		system("cls");
    		cout <<"Attack...Please wait."<<endl;
    		Sleep(2000);
    		break;
    	}
    
    	return true;
    }
    
    
    int ArmyDo::ashow(Nation &nation,const Show &show, const VillagerDo &villagerdo, const Player &player, Army& army,Build build, UpgradDo& upgrader, Workshop workshop) const
    {
    
    	int armydochoice;
    	bool looparmydo = true;
    	int armydelete;
    
    	do
    	{
    
    
    		system("cls");
    
    		cout <<"You got "<<army.getArmy()<<" army.\n\n"<<endl;
    
    		cout <<"1.Send your army to attack."<<endl;
    		cout <<"2.Delete some of your army."<<endl;
    		cout <<"3.Go back"<<endl;
    		cout <<">>";
    		cin >> armydochoice;
    
    		switch (armydochoice)
    		{
    		case 1:
    			break;
    
    		case 2:
    			if (army.aArmy == 0)
    			{
    				system("cls");
    				cout <<"You don't even got 1 army.Press enter to continue."<<endl;
    				cin.get();
    				cin.get();
    				looparmydo = false;
    				ashow(nation, show, villagerdo, player, army, build, upgrader, workshop);
    			}
    			else if(army.aArmy > 0)
    			{
    				system("cls");
    				cout <<"You got "<<army.getArmy()<<" army.\n\n"<<endl;
    				cout <<"How much of your army you want to delete?"<<endl;
    				cin >> armydelete;
    				if(armydelete > army.aArmy)
    				{
    					system("cls");
    					cout <<"You don't even got this much army!Press enter to continue."<<endl;
    					cin.get();
    					cin.get();
    					looparmydo = false;
    					ashow(nation, show, villagerdo, player, army, build, upgrader, workshop);
    				}
    				else if (armydelete <= army.aArmy)
    				{
    					system("cls");
    					cout <<"You have deleted "<<armydelete<<" army."<<endl;
    					army.aArmy = army.aArmy - armydelete;
    					looparmydo = false;
    					ashow(nation, show, villagerdo, player, army, build, upgrader, workshop);
    				}
    			}
    
    			break;
    
    		case 3:
    			looparmydo = false;
    			show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    			break;
    		}
    
    	}while (looparmydo == true);
    
    
    	return true;
    
    }
    
    int ArmyDo::aCreateShow(Nation& nation, const Show& show, const VillagerDo& villagerdo, const Player& player, Army& army,Build build, UpgradDo& upgrader, Workshop workshop) const
    {
    	int armycreatechoice;
    	bool looparmycreate = true;
    	int howmucharmy;
    
    	do
    	{
    
    
    		system("cls");
    
    		cout <<"You got "<<army.getArmy()<<" army."<<endl;
    		cout <<"Total population of "<<nation.getPopulation(army)<<"/"<<nation.getMaxPopulation()<<endl;
    		cout <<"\n\n";
    
    		cout <<"1.Create Army.(1 army = 75 food, 50 gold)"<<endl;
    		cout <<"2.Go back."<<endl;
    		cout <<">>";
    		cin >> armycreatechoice;
    
    		switch (armycreatechoice)
    		{
    		case 1:
    			system("cls");
    			cout <<"How much army do you want to create?"<<endl;
    			cout <<">>";
    			cin >> howmucharmy;
    
    			looparmycreate = false;
    			if (howmucharmy == 0)
    			{
    				looparmycreate = false;
    				system("cls");
    				cout <<"Please select a higher number then 0.Press enter to continue"<<endl;
    				cin.get();
    				cin.get();
    				show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    				break;
    			}
    
    			else if (howmucharmy == 1)
    			{
    				if (nation.getGold() > 50 * howmucharmy && nation.getFood() > 75 * howmucharmy)
    				{
    
    					if (nation.getPopulation(army) + howmucharmy > nation.getMaxPopulation())
    					{
    						looparmycreate = false;
    						system("cls");
    						cout <<"You need more houses.Press enter to continue..."<<endl;
    						cin.get();
    						cin.get();
    						show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    						break;
    					}
    
    					else if (nation.getPopulation(army) + howmucharmy <= nation.getMaxPopulation())
    					{
    						looparmycreate = false;
    						system("cls");
    						nation.nFood = nation.nFood - (75 * howmucharmy);
    						nation.nGold = nation.nGold - (50 * howmucharmy);
    						army.aArmy = army.aArmy + howmucharmy;
    						nation.nPopulation = nation.nPopulation + howmucharmy;
    						cout <<"You have created "<<howmucharmy <<" new army."<<endl;
    						cout <<"You now have "<<army.aArmy<<" army.Press enter to continue."<<endl;
    						cin.get();
    						cin.get();
    						show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    						break;
    					}
    				}
    
    				else if (nation.getGold() < 50 * howmucharmy || nation.getFood() < 75 * howmucharmy)
    				{
    					looparmycreate = false;
    					system("cls");
    					cout <<"You don't got enough resources.Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    					break;
    				}
    
    
    
    			}
    
    
    
    			if (nation.getGold() > 50 * howmucharmy && nation.getFood() > 75 * howmucharmy)
    			{
    
    				if (nation.getPopulation(army) + howmucharmy > nation.getMaxPopulation())
    				{
    					looparmycreate = false;
    					system("cls");
    					cout <<"You need more houses.Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    					break;
    				}
    
    				else if (nation.getPopulation(army) + howmucharmy <= nation.getMaxPopulation())
    				{
    					looparmycreate = false;
    					system("cls");
    					nation.nFood = nation.nFood - (75 * howmucharmy);
    					nation.nGold = nation.nGold - (50 * howmucharmy);
    					army.aArmy = army.aArmy + howmucharmy;
    					nation.nPopulation = nation.nPopulation + howmucharmy;
    					cout <<"You have created "<<howmucharmy <<" new army."<<endl;
    					cout <<"You now have "<<army.aArmy<<" army.Press enter to continue."<<endl;
    					cin.get();
    					cin.get();
    					show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    					break;
    				}
    			}
    			else if (nation.getGold() < 50 * howmucharmy || nation.getFood() < 75 * howmucharmy)
    			{
    				looparmycreate = false;
    				system("cls");
    				cout <<"You don't got enough resources.Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    				break;
    			}
    
    			break;
    
    		case 2:
    			looparmycreate = false;
    			show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    			break;
    
    		}
    
    	}while (looparmycreate == true);
    
    	return true;
    
    }
    
    int ArmyDo::aInfo(Nation &nation, const Show &show, const VillagerDo &villagerdo, const Player &player, Army &army,Build build, UpgradDo& upgrader, Workshop workshop) const
    {
    	int armyinfochoice;
    	bool looparmyinfo = true;
    
    	do
    	{
    
    
    		system("cls");
    
    		cout <<"You got "<<army.getArmy()<<" army."<<endl;
    		cout <<"The army got an attack of "<<army.getAttack()<<" ."<<endl;
    		cout <<"The army got a defense of "<<army.getDefense()<<" ."<<endl;
    		cout <<"1.Go back"<<endl;
    		cout <<">>";
    		cin >> armyinfochoice;
    
    		switch (armyinfochoice)
    		{
    		case 1:
    			looparmyinfo = false;
    			show.WhatToDo(nation, player, army, villagerdo, *this, build, upgrader, workshop);
    			break;
    
    
    		}
    
    	}while (looparmyinfo == true);
    
    	return true;
    
    }

    ArmyDo.h

    Code:
    //army class
    #ifndef ARMYDO_H
    #define ARMYDO_H
    
    //#include "VillagerDo.h"
    //#include "Player.h"
    //#include "Nation.h"
    //#include "Show.h"
    //#include "Army.h"
    //#include "Build.h"
    #include "Upgrader.h"
    #include "WorkShop.h"
    
    
    
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    class Nation;
    class Show;
    class VillagerDo;
    class Player;
    class Army;
    class Build;
    class UpgradDo;
    class WorkShop;
    
    class ArmyDo
    {
    
    
    public:
    	int aAttack(Nation& nation, const Show& show, const VillagerDo& villagerdo, const Player& player, Army& army, Build build, UpgradDo& upgrader, Workshop workshop) const;
    	int ashow(Nation& nation, const Show& show, const VillagerDo& villagerdo, const Player& player, Army& army, Build build, UpgradDo& upgrader, Workshop workshop) const;
    	int aInfo(Nation& nation, const Show& show, const VillagerDo& villagerdo, const Player& player, Army& army, Build build, UpgradDo& upgrader, Workshop workshop) const;
    	int aCreateShow(Nation& nation, const Show& show, const VillagerDo& villagerdo, const Player& player, Army& army, Build build, UpgradDo& upgrader, Workshop workshop) const;
    
    public:
    
    	//Army attack
    
    	//Quest
    
    
    
    };
    
    #endif


    Build.cpp

    Code:
    //Build
    #include "stdafx.h"
    #include "Build.h"
    #include "Upgrader.h"
    #include "WorkShop.h"
    #include <iostream>
    
    using std::cout;
    using std::endl;
    using std::cin;
    
    
    
    
    //Build show
    int Build::bshow(Nation &nation, const Show &show,Army &army, const Player &player, const ArmyDo &armydo, const VillagerDo& villagerdo, UpgradDo& upgrader, Workshop workshop)
    {
    
    	int buildchoice;
    	loopbuild = true;
    
    
    
    	while(loopbuild == true)
    	{
    
    		system("cls");
    
    		cout <<"1.Build a house (100 wood, 30 food, 20 stone, 50 gold)(+5 max population)"<<endl;
    		cout <<"2.Build a hospital (500 wood, 100 food, 200 stone, 300 gold)(+2 villager)"<<endl;
    		cout <<"3.Build an upgrader.(5000 wood, 1000 food, 6000 stone, 15000 gold)"<<endl;
    		cout <<"4.Build a WorkShop.(500 wood, 500 food, 500 stone, 500 gold)"<<endl;
    		cout <<"5.Go back"<<endl;
    		cout <<">>";
    		cin >> buildchoice;
    
    		switch (buildchoice)
    		{
    		case 1:
    
    			if (nation.getWood() < 100 || nation.getFood() < 30 || nation.getStone() < 20 || nation.getGold() < 50)
    			{ 
    
    				system("cls");
    				cout <<"You don't got enough resources!Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    
    			else if (nation.getWood() >= 100 && nation.getFood() >= 30 && nation.getStone() >= 20 && nation.getGold() >= 50)
    			{
    				system("cls");
    				nation.nFood = nation.nFood - 30;
    				nation.nGold = nation.nGold - 50;
    				nation.nWood = nation.nWood - 100;
    				nation.nStone = nation.nStone - 20;
    				nation.nMaxPopulation = nation.nMaxPopulation + 5;
    				cout <<"You just built a house.Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    			break;
    
    		case 2:
    
    			if (nation.getWood() < 500 || nation.getFood() < 100 || nation.getStone() < 200 || nation.getGold() < 300)
    			{
    
    				system("cls");
    				cout <<"You don't got enough resources!Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    
    			if (nation.getWood() >= 500 && nation.getFood() >= 100 && nation.getStone() >= 200 && nation.getGold() >= 300)
    			{
    
    				system("cls");
    				nation.nFood = nation.nFood - 100;
    				nation.nGold = nation.nGold - 300;
    				nation.nWood = nation.nWood - 500;
    				nation.nStone = nation.nStone - 200;
    				nation.nVillager = nation.nVillager + 2;
    				cout <<"You just built a hospital.Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    			break;
    
    		case 3:
    
    			if (nation.getWood() >= 5000 && nation.getFood() >= 1000 && nation.getStone() >= 6000 && nation.getGold() >= 15000)
    			{
    
    				if (upgrader.UpgradShow() == "7.Upgrad stuff")
    				{
    					system("cls");
    					cout <<"You already got an upgrader!Press enter to continue..."<<endl;
    					loopbuild = false;
    					cin.get();
    					cin.get();
    					bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    				}
    
    				system("cls");
    				nation.nFood = nation.nFood - 1000;
    				nation.nGold = nation.nGold - 15000;
    				nation.nWood = nation.nWood - 5000;
    				nation.nStone = nation.nStone - 6000;
    				upgrader.setUpgradeShow("7.Upgrad stuff");
    				cout <<"You just built an upgrader.Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    
    
    			else if (nation.getWood() < 5000 || nation.getFood() < 1000 || nation.getStone() < 6000 || nation.getGold() < 15000)
    			{
    				system("cls");
    				cout <<"You don't got enough resources!Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    			break;
    
    		case 4:
    
    			if (nation.getWood() >= 500 && nation.getFood() >= 500 && nation.getStone() >= 500 && nation.getGold() >= 500)
    			{
    
    				if (nation.WorkShopShow() == "gotworkshop")
    				{
    					system("cls");
    					cout <<"You already got a WorkShop!Press enter to continue..."<<endl;
    					loopbuild = false;
    					cin.get();
    					cin.get();
    					bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    				}
    
    				system("cls");
    				nation.nFood = nation.nFood - 500;
    				nation.nGold = nation.nGold - 500;
    				nation.nWood = nation.nWood - 500;
    				nation.nStone = nation.nStone - 500;
    				nation.setWorkShopShow("gotworkshop");
    				cout <<"You just built a WorkShop.Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    
    
    			else if (nation.getWood() < 500 || nation.getFood() < 500 || nation.getStone() < 500 || nation.getGold() < 500)
    			{
    				system("cls");
    				cout <<"You don't got enough resources!Press enter to continue..."<<endl;
    				loopbuild = false;
    				cin.get();
    				cin.get();
    				bshow(nation, show, army, player, armydo, villagerdo, upgrader, workshop);
    			}
    			break;
    
    		case 5:
    			loopbuild = false;
    			show.WhatToDo(nation, player, army, villagerdo, armydo, *this, upgrader, workshop);
    			break;
    		}
    
    
    
    	}
    
    	return true;
    
    }
    
    
    //BUILD CODE
    
    /*
    if (nation.getWood() < 500 || nation.getFood() < 500 || nation.getStone() < 500 || nation.getGold() < 500)
    { 
    
    system("cls");
    cout <<"You don't got enough resources!Press enter to continue..."<<endl;
    loopbuild = false;
    cin.get();
    cin.get();
    show.WhatToDo(nation, player, army, villagerdo, armydo, *this, upgrader);
    }
    
    else if (nation.getWood() >= 500 && nation.getFood() >= 500 && nation.getStone() >= 500 && nation.getGold() >= 500)
    {
    system("cls");
    nation.nFood = nation.nFood - 30;
    nation.nGold = nation.nGold - 50;
    nation.nWood = nation.nWood - 100;
    nation.nStone = nation.nStone - 20;
    nation.nMaxPopulation = nation.nMaxPopulation + 5;
    cout <<"You just built a house.Press enter to continue..."<<endl;
    loopbuild = false;
    cin.get();
    cin.get();
    show.WhatToDo(nation, player, army, villagerdo, armydo, *this, upgrader);
    }
    
    */

    Build.h

    Code:
    //Build class
    #ifndef BUILD_H
    #define BUILD_H
    
    #include "Nation.h"
    #include "Show.h"
    #include "Army.h"
    #include "Player.h"
    #include "WorkShop.h"
    #include "ArmyDo.h"
    
    
    
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    
    
    class Build
    {
    
    public:
    
    
    	int bshow(Nation& nation, const Show& show, Army& army, const Player& player, const ArmyDo& armydo, const VillagerDo& villagerdo, UpgradDo& upgrader, Workshop workshop);
    
    
    public:
    
    
    	bool loopbuild;
    
    };
    
    
    
    
    #endif

    Nation.cpp

    Code:
    #include "stdafx.h"
    #include "Army.h"
    #include "Nation.h"
    #include "WorkShop.h"
    #include <string>
    
    
    //Contruct
    Nation::Nation()
    {
    
    	nGold = 20000;
    	nFood = 20000;
    	nWood = 20000;
    	nStone = 20000;
    	nVillager = 3;
    	nMaxPopulation = 5;
    	nPopulation = 0;
    	nWorkingFoodVillager = 0;
    	nWorkingGoldVillager = 0;
    	nWorkingStoneVillager = 0;
    	nWorkingWoodVillager = 0;
    }
    
    //Destruct
    Nation::~Nation()
    {
    
    }
    
    //NAME
    std::string Nation::getName() const
    {
    	return nName;
    }
    void Nation::setName(std::string name)
    {
    	nName = name;
    }
    void Nation::changeName(std::string changename)
    {
    	nName = changename;
    }
    
    
    //GOLD
    int Nation::getGold() const
    {
    	return nGold;
    }
    void Nation::setGold(int gold)
    {
    	nGold = gold;
    }
    
    
    //STONE
    int Nation::getStone() const
    {
    	return nStone;
    }
    void Nation::setStone(int stone)
    {
    	nStone = stone;
    }
    
    
    //WOOD
    int Nation::getWood() const
    {
    	return nWood;
    }
    void Nation::setWood(int wood)
    {
    	nWood = wood;
    }
    
    
    //FOOD
    int Nation::getFood() const
    {
    	return nFood;
    }
    void Nation::setFood(int food)
    {
    	nFood = food;
    }
    
    
    //##=VILLAGERS
    int Nation::getVillager() const
    {
    	return nVillager;
    }
    void Nation::setVillager(int villager)
    {
    	nVillager = villager;
    }
    
    
    //WORKING Food VILLAGERS
    int Nation::getWorkingFoodVillager() const
    {
    	return nWorkingFoodVillager;
    }
    void Nation::setWorkingFoodVillager(int workingfoodvillager)
    {
    	nWorkingFoodVillager = workingfoodvillager;
    }
    
    //WORKING Gold VILLAGERS
    int Nation::getWorkingGoldVillager() const
    {
    	return nWorkingGoldVillager;
    }
    void Nation::setWorkingGoldVillager(int workinggoldvillager)
    {
    	nWorkingGoldVillager = workinggoldvillager;
    }
    
    //WORKING Stone VILLAGERS
    int Nation::getWorkingStoneVillager() const
    {
    	return nWorkingStoneVillager;
    }
    void Nation::setWorkingStoneVillager(int workingstonevillager)
    {
    	nWorkingStoneVillager = workingstonevillager;
    }
    
    //WORKING Wood VILLAGERS
    int Nation::getWorkingWoodVillager() const
    {
    	return nWorkingWoodVillager;
    }
    void Nation::setWorkingWoodVillager(int workingwoodvillager)
    {
    	nWorkingWoodVillager = workingwoodvillager;
    }
    
    
    //POPULATION
    int Nation::getPopulation(const Army& army) const
    {
    	return nVillager + army.getArmy() + nWorkingFoodVillager + nWorkingGoldVillager + nWorkingStoneVillager + nWorkingWoodVillager;
    }
    void Nation::setPopulation(int population)
    {
    	nPopulation = population;
    }
    
    //Max population
    int Nation::getMaxPopulation() const
    {
    	return nMaxPopulation;
    }
    void Nation::setMaxPopulation(int maxpopulation)
    {
    	nMaxPopulation = maxpopulation;
    }
    
    
    
    
    //GET THE RESOURCE
    int Nation::getAndIncreaseFood()
    {
    
    	nFood += nWorkingFoodVillager;
    	return nFood;
    
    }
    
    int Nation::getAndIncreaseGold()
    {
    	nGold += nWorkingGoldVillager;
    	return nGold;
    }
    
    int Nation::getAndIncreaseStone()
    {
    	nStone += nWorkingStoneVillager;
    	return nStone;
    }
    int Nation::getAndIncreaseWood()
    {
    	nWood += nWorkingWoodVillager;
    	return nWood;
    }
    
    
    //GOT WORKSHOP
    std::string Nation::WorkShopShow()
    {
    	return workshopshow;
    }
    
    void Nation::setWorkShopShow(string nworkshopshow)
    {
    	workshopshow = nworkshopshow;
    }

    Nation.h

    Code:
    //Nation class
    #ifndef NATION_H
    #define NATION_H
    
    
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    #include <string>
    #include "Army.h"
    
    class Nation
    {
    
    public:
    
    	//Construct
    	Nation();
    	//Destruct
    	~Nation();
    	//Name
    	std::string getName() const;
    	//set nation name
    	void setName(std::string name);
    	//change nation name
    	void changeName(std::string changename);
    	//Gold
    	int getGold() const;
    	//set gold
    	void setGold(int gold);
    	//Stone
    	int getStone() const;
    	//set stone
    	void setStone(int stone);
    	//Wood
    	int getWood() const;
    	//set wood
    	void setWood(int wood);
    	//Food
    	int getFood() const;
    	//set food
    	void setFood(int food);
    	//read Villager
    	int getVillager() const;
    	//set villagers
    	void setVillager(int villager);
    	//read working food villagers
    	int getWorkingFoodVillager() const;
    	//set the working food villagers
    	void setWorkingFoodVillager(int workingfoodvillager);
    	//read the working gold villagers
    	int getWorkingGoldVillager() const;
    	//set the working gold villagers
    	void setWorkingGoldVillager(int workinggoldvillager);
    	//read working stone villager
    	int getWorkingStoneVillager() const;
    	//set the working stone villager
    	void setWorkingStoneVillager(int workingstonevillager);
    	//read the working wood villagers
    	int getWorkingWoodVillager() const;
    	//set the working wood villager
    	void setWorkingWoodVillager(int workingwoodvillager);
    	//read Population
    	int getPopulation(const Army& army) const;
    	//set population
    	void setPopulation(int population);
    	//Read max population
    	int getMaxPopulation() const;
    	//set max population
    	void setMaxPopulation(int maxpopulation);
    	//sendvillagerfood
    	int sendVillagerFood() const;
    
    	//Get the resource
    	int getAndIncreaseFood();
    	int getAndIncreaseGold();
    	int getAndIncreaseStone();
    	int getAndIncreaseWood();
    
    	std::string WorkShopShow();
    	void setWorkShopShow(std::string nworkshopshow);
    
    
    
    
    public:
    	//gold
    	std::string nName;
    	//resources
    	int nGold;
    	//wood
    	int nWood;
    	//stone
    	int nStone;
    	//food
    	int nFood;
    	//villagers
    	int nVillager;
    	//working villagers
    	int nWorkingFoodVillager;
    	int nWorkingGoldVillager;
    	int nWorkingWoodVillager;
    	int nWorkingStoneVillager;
    	//Population
    	int nPopulation;
    	//max population
    	int nMaxPopulation;
    
    	int workforres;
    
    	std::string workshopshow;
    
    
    
    
    };
    
    #endif // NATION_H

    Player.cpp

    Code:
    #include "stdafx.h"
    #include "Player.h"
    #include <string>
    
    
    //Construct
    Player::Player()
    {
    	pName = "";
    }
    
    Player::~Player()
    {
    
    }
    
    
    //Player Name
    
    std::string Player::getName() const
    {
    	return pName;
    }
    void Player::setName(std::string playername)
    {
    	pName = playername;
    }

    Player.h

    Code:
    //Player class
    #ifndef PLAYER_H
    #define PLAYER_H
    
    #include <string>
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    
    class Player
    {
    
    
    
    public:
    
    	Player();
    	~Player();
    
    	std::string getName() const; //Read the name of the player
    	void setName(std::string playername); //set the name of the player
    
    
    private:
    
    	std::string pName;
    };
    
    #endif // PLAYER_H

    Show.cpp

    Code:
    #include "stdafx.h"
    #include "Army.h"
    #include "Player.h"
    #include "Nation.h"
    #include "Show.h"
    #include "Build.h"
    #include "ArmyDo.h"
    #include "VillagerDo.h"
    #include "Upgrader.h"
    #include "WorkShop.h"
    #include <iostream>
    
    
    using std::cout;
    using std::endl;
    using std::cin;
    
    
    int Show::WhatToDo(Nation& nation, const Player& player,Army& army, const VillagerDo& villagerdo, const ArmyDo& armydo, Build build, UpgradDo upgrader, Workshop workshop) const
    {
    
    	int whattodochoice = 0;
    	bool loopwhattodo = true;
    
    	while(loopwhattodo == true)
    	{
    		system("cls");
    		cout <<" --INFORMATION-- "<<endl;
    		cout <<"Name: "<<player.getName()<<endl;
    		cout <<"Nation Name: "<<nation.getName()<<endl;
    		cout <<"Population: "<<nation.getPopulation(army)<<"/"<<nation.getMaxPopulation()<<endl;
    		cout <<"Gold: "<<nation.getGold()<<endl;
    		cout <<"Stone: "<<nation.getStone()<<endl;
    		cout <<"Wood: "<<nation.getWood()<<endl;
    		cout <<"Food: "<<nation.getFood()<<endl;
    
    		cout <<" --ARMY-- "<<endl;
    		cout <<"Villagers that are doing nothing: "<<nation.getVillager()<<endl;
    		cout <<"Villagers that are working on food: "<<nation.getWorkingFoodVillager()<<endl;
    		cout <<"Villagers that are working on gold: "<<nation.getWorkingGoldVillager()<<endl;
    		cout <<"Villagers that are working on stone: "<<nation.getWorkingStoneVillager()<<endl;
    		cout <<"Villagers that are working on wood: "<<nation.getWorkingWoodVillager()<<endl;
    		cout <<"Army: "<<army.getArmy()<<endl;
    		cout <<endl;
    		cout <<"8.Work mode";
    
    		cout <<"\n\n";
    
    		cout <<"1.Do something with villagers."<<"            "<<upgrader.UpgradShow()<<endl;
    		cout <<"2.Do something with your army."<<endl;
    		cout <<"3.Build."<<endl;
    		cout <<"4.Create army."<<endl;
    		cout <<"5.Army information."<<endl;
    		cout <<"6.Quit"<<endl;
    		cout <<">>";
    		cin >> whattodochoice;
    
    
    		switch (whattodochoice)
    		{
    
    		case 1:
    			loopwhattodo = false;
    			villagerdo.vshow(nation, *this, army, player, armydo, build, upgrader, workshop);
    			break;
    		case 2:
    			loopwhattodo = false;
    			armydo.ashow(nation, *this, villagerdo, player, army, build, upgrader, workshop);
    			break;
    		case 3:
    			loopwhattodo = false;
    			build.bshow(nation, *this, army, player, armydo, villagerdo, upgrader, workshop);
    			break;
    		case 4:
    			loopwhattodo = false;
    			armydo.aCreateShow(nation, *this, villagerdo, player, army, build, upgrader, workshop);
    			break;
    		case 5:
    			loopwhattodo = false;
    			armydo.aInfo(nation, *this, villagerdo, player, army, build, upgrader, workshop);
    			break;
    		case 6:
    			return 0;
    		case 7:
    			if (upgrader.UpgradShow() == "7.Upgrad stuff")
    			{
    				loopwhattodo = false;
    				system("cls");
    				upgrader.ushow(nation, player, army, villagerdo, armydo, build, *this, workshop);
    			}
    			else if(upgrader.UpgradShow() != "7.Upgrad stuff")
    			{
    
    				loopwhattodo = false;
    				WhatToDo(nation, player, army, villagerdo, armydo, build, upgrader, workshop);
    				break;
    		case 8:
    			if (nation.WorkShopShow() != "gotworkshop")
    		 {
    			 system("cls");
    			 cout <<"You don't even got a WorkShop!Press enter to continue."<<endl;
    			 cin.get();
    			 cin.get();
    			 loopwhattodo = false;
    			 WhatToDo(nation, player, army, villagerdo, armydo, build, upgrader, workshop);
    		 }
    			else if(nation.WorkShopShow() == "gotworkshop")
    		 {
    
    			 workshop.workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, *this);
    
    		 }
    			break;
    
    			}
    
    		}
    
    	}
    
    
    	return true;
    
    }

    Show.h

    Code:
    //Show class
    #ifndef SHOW_H
    #define SHOW_H
    
    #include "Player.h"
    #include "Nation.h"
    #include "Army.h"
    #include "Build.h"
    #include "ArmyDo.h"
    #include "WorkShop.h"
    #include "Upgrader.h"
    
    class VillagerDo;
    class ArmyDo;
    class WorkShop;
    
    
    
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    
    class Show
    {
    public:
    
    	int WhatToDo(Nation& nation, const Player& player,Army& army, const VillagerDo& villagerdo, const ArmyDo& armydo,Build build, UpgradDo upgrader, Workshop workshop) const; //Show the list of things you can do
    
    
    
    
    };
    
    #endif // SHOW_H


    Upgrader.cpp

    Code:
    #include "stdafx.h"
    #include "Nation.h"
    #include "Army.h"
    #include "VillagerDo.h"
    #include "Player.h"
    #include "ArmyDo.h"
    #include "Build.h"
    #include "Show.h"
    #include "WorkShop.h"
    #include <iostream>
    #include "Upgrader.h"
    
    
    
    
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    
    
    int UpgradDo::ushow(Nation& nation, const Player& player, Army& army, const VillagerDo& villagerdo, const ArmyDo& armydo, Build build, Show show, Workshop workshop) const
    {
    	int upgraddochoice;
    	bool loopupgraddo = true;
    
    	do
    	{
    
    
    
    
    
    		system("cls");
    		cout <<"1.Upgrad Army(5000 food, 5000 wood, 5000 stone, 5000 gold"<<endl;
    		cout <<"2.Go back"<<endl;
    		cout <<">>"<<endl;
    		cin >> upgraddochoice;
    
    		switch(upgraddochoice)
    		{
    
    		case 1:
    			if (nation.getWood() < 5000 || nation.getFood() < 5000 || nation.getStone() < 5000 || nation.getGold() < 5000)
    			{
    				loopupgraddo = false;
    				system("cls");
    				cout <<"You don't got enough resources!Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				show.WhatToDo(nation, player, army, villagerdo, armydo, build, *this, workshop);
    
    			}
    
    			if (nation.getWood() >= 5000 && nation.getFood() >= 5000 && nation.getStone() >= 5000 && nation.getGold() >= 5000)
    			{
    
    				loopupgraddo = false;
    				system("cls");
    				nation.nFood = nation.nFood - 5000;
    				nation.nGold = nation.nGold - 5000;
    				nation.nWood = nation.nWood - 5000;
    				nation.nStone = nation.nStone - 5000;
    				army.aAttack = army.aAttack + 5;
    				army.aDefense = army.aDefense + 3;
    				cout <<"You have upgraded your army.Press enter to continue."<<endl;
    				cin.get();
    				cin.get();
    				show.WhatToDo(nation, player, army, villagerdo, armydo, build, *this, workshop);
    			}
    			break;
    		case 2:
    			loopupgraddo = false;
    			show.WhatToDo(nation, player, army, villagerdo, armydo, build, *this, workshop);
    			break;
    
    		}
    
    	} while (loopupgraddo == true);
    
    	return true;
    
    
    }
    
    
    
    
    
    
    
    
    
    
    //Show the upgrader
    string UpgradDo::UpgradShow()
    {
    	return upgradeshow;
    }
    
    void UpgradDo::setUpgradeShow(string nupgradshow)
    {
    	upgradeshow = nupgradshow;
    }

    Upgrader.h

    Code:
    #ifndef UPGRADER_H
    #define UPGRADER_H
    
    #include "Nation.h"
    #include "Army.h"
    #include "VillagerDo.h"
    #include "Player.h"
    #include "ArmyDo.h"
    #include "Build.h"
    #include "Show.h"
    #include "WorkShop.h"
    #include <iostream>
    #include "Upgrader.h"
    
    class Show;
    class Army;
    class Nation;
    class VillagerDo;
    class ArmyDo;
    class Build;
    
    
    
    
    using std::string;
    
    
    class UpgradDo
    {
    
    public:
    
    	//See the upgrader
    	string UpgradShow();
    	void setUpgradeShow(string nupgradshow);
    
    
    	int ushow(Nation& nation, const Player& player,Army& army, const VillagerDo& villagerdo, const ArmyDo& armydo, Build build,Show show, Workshop workshop) const;
    
    
    
    public:
    
    	string upgradeshow;
    
    
    
    
    };
    
    
    
    
    
    #endif

    VillagerDo.cpp

    Code:
    #include "stdafx.h"
    #include "Player.h"
    #include "Nation.h"
    #include "Army.h"
    #include "Show.h"
    #include "Build.h"
    #include "Upgrader.h"
    #include "VillagerDo.h"
    #include "WorkShop.h"
    #include <iostream>
    
    using std::cout;
    using std::cin;
    using std::endl;
    
    
    
    
    int VillagerDo::vshow(Nation& nation, const Show& show,Army& army, const Player& player, const ArmyDo& armydo,Build& build, UpgradDo& upgrader, Workshop workshop) const
    {
    	int villagerdochoice;
    	bool loopvillagerdo = true;
    
    	do
    	{
    		system("cls");
    
    
    
    		cout <<"There's "<<nation.getVillager()<<" villager(s) that (is)are not working.\n\n"<<endl;
    
    		cout <<"1.Send a villager to get food"<<endl;
    		cout <<"2.Send a villager to get gold"<<endl;
    		cout <<"3.Send a villager to get stone"<<endl;
    		cout <<"4.Send a villager to get wood"<<endl;
    		cout <<"5.Remove a villager from working."<<endl;
    		cout <<"6.Go back"<<endl;
    		cout <<">>";
    		cin >> villagerdochoice;
    
    		switch (villagerdochoice)
    		{
    		case 1:
    			if(nation.nVillager >= 1)
    			{
    				system("cls");
    				nation.nVillager = nation.nVillager - 1;
    				nation.nWorkingFoodVillager = nation.nWorkingFoodVillager + 1;
    				cout <<"Now there's "<<nation.nWorkingFoodVillager<<" villager(s) that is(are) working for food."<<endl;
    				cout <<"Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    			else if(nation.nVillager < 1)
    			{
    				system("cls");
    				cout <<"You don't even got one villager that is not working.Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    			break;
    
    		case 2:
    			if(nation.nVillager >= 1)
    			{
    				system("cls");
    				nation.nVillager = nation.nVillager - 1;
    				nation.nWorkingGoldVillager = nation.nWorkingGoldVillager + 1;
    				cout <<"Now there's "<<nation.nWorkingGoldVillager<<" villager(s) that is(are) working for gold"<<endl;
    				cout <<"Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    			else if(nation.nVillager < 1)
    			{
    				system("cls");
    				cout <<"You don't even got one villager that is not working.Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    			break;
    
    		case 3:
    			if(nation.nVillager >= 1)
    			{
    				system("cls");
    				nation.nVillager = nation.nVillager - 1;
    				nation.nWorkingStoneVillager = nation.nWorkingStoneVillager + 1;
    				cout <<"Now there's "<<nation.nWorkingStoneVillager<<" villager(s) that is(are) working for stone"<<endl;
    				cout <<"Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    			else if(nation.nVillager < 1)
    			{
    				system("cls");
    				cout <<"You don't even got one villager that is not working.Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    
    			break;
    		case 4:
    			if(nation.nVillager >= 1)
    			{
    				system("cls");
    				nation.nVillager = nation.nVillager - 1;
    				nation.nWorkingWoodVillager = nation.nWorkingWoodVillager + 1;
    				cout <<"Now there's "<<nation.nWorkingWoodVillager<<" villager(s) that is(are) working for wood"<<endl;
    				cout <<"Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    			else if(nation.nVillager < 1)
    			{
    				system("cls");
    				cout <<"You don't even got one villager that is not working.Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    			}
    
    			break;
    
    		case 5:
    			int removevillagerchoice;
    			system("cls");
    			cout <<"1.Remove one from food"<<endl;
    			cout <<"2.Remove one from gold"<<endl;
    			cout <<"3.Remove one from stone"<<endl;
    			cout <<"4.Remove one from wood"<<endl;
    			cout <<"5.Go back"<<endl;
    			cout <<">>";
    			cin >> removevillagerchoice;
    
    			switch(removevillagerchoice)
    			{
    			case 1:
    				if (nation.nWorkingFoodVillager == 0)
    				{
    					system("cls");
    					cout <<"There are no villagers that are working for food.Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				else if (nation.nWorkingFoodVillager >= 1)
    				{
    					system("cls");
    					nation.nWorkingFoodVillager = nation.nWorkingFoodVillager - 1;
    					nation.nVillager = nation.nVillager + 1;
    					cout <<"One villager has stopped working. Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				break;
    
    			case 2:
    				if (nation.nWorkingGoldVillager == 0)
    				{
    					system("cls");
    					cout <<"There are no villagers that are working for gold.Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				else if (nation.nWorkingGoldVillager >= 1)
    				{
    					system("cls");
    					nation.nWorkingGoldVillager = nation.nWorkingGoldVillager - 1;
    					nation.nVillager = nation.nVillager + 1;
    					cout <<"One villager has stopped working. Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				break;
    
    			case 3:
    				if (nation.nWorkingStoneVillager == 0)
    				{
    					system("cls");
    					cout <<"There are no villagers that are working for stone.Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				else if (nation.nWorkingStoneVillager >= 1)
    				{
    					system("cls");
    					nation.nWorkingStoneVillager = nation.nWorkingStoneVillager - 1;
    					nation.nVillager = nation.nVillager + 1;
    					cout <<"One villager has stopped working. Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				break;
    			case 4:
    
    				if (nation.nWorkingWoodVillager == 0)
    				{
    					system("cls");
    					cout <<"There are no villagers that are working for wood.Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				else if (nation.nWorkingWoodVillager >= 1)
    				{
    					system("cls");
    					nation.nWorkingWoodVillager = nation.nWorkingWoodVillager - 1;
    					nation.nVillager = nation.nVillager + 1;
    					cout <<"One villager has stopped working. Press enter to continue..."<<endl;
    					cin.get();
    					cin.get();
    					loopvillagerdo = false;
    					vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				}
    				break;
    
    			case 5:
    				loopvillagerdo = false;
    				vshow(nation, show, army, player, armydo, build, upgrader, workshop);
    				break;
    
    			}
    			break;
    		case 6:
    			loopvillagerdo = false;
    			show.WhatToDo(nation, player, army, *this, armydo, build, upgrader, workshop);
    			break;
    
    		}
    
    
    	}while(loopvillagerdo == true);
    
    	return true;
    
    }

    VillagerDo.h

    Code:
    #ifndef VILLAGERDO_H
    #define VILLAGERDO_H
    
    #include "Player.h"
    #include "Nation.h"
    #include "Army.h"
    #include "Show.h"
    #include "Upgrader.h"
    #include "WorkShop.h"
    #include "Build.h"
    
    
    
    class Show;
    class Army;
    class Nation;
    class UpgradDo;
    class Build;
    class ArmyDo;
    
    //using std::endl;
    //using std::cout;
    //using std::cin;
    //using std::string;
    
    class VillagerDo
    {
    
    public:
    
    	int vshow(Nation& nation, const Show& show, Army& army, const Player& player, const ArmyDo& armydo, Build& build, UpgradDo& upgrader, Workshop workshop) const;
    
    };
    
    #endif

    WorkShop.cpp

    Code:
    #include "stdafx.h"
    #include "Army.h"
    #include "Player.h"
    #include "Nation.h"
    #include "Show.h"
    #include "Build.h"
    #include "ArmyDo.h"
    #include "VillagerDo.h"
    #include "Upgrader.h"
    #include "WorkShop.h"
    
    
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;
    
    int Workshop::workshopshow(Nation& nation, const Player& player, Army& army, const VillagerDo& villagerdo, const ArmyDo& armydo,const Build& build, UpgradDo& upgrader, Show show)
    {
    
    	bool loopworking = true;
    
    	while(loopworking)
    	{
    
    
    
    		system("cls");
    		cout <<"Food: "<<nation.getFood()<<endl;
    		cout <<"Gold: "<<nation.getGold()<<endl;
    		cout <<"Stone: "<<nation.getStone()<<endl;
    		cout <<"Wood: "<<nation.getWood()<<endl;
    
    		cout <<"\n\n\n\n";
    
    		cout <<"1.Get Food.Click the fastest you can."<<endl;
    		cout <<"2.Get Gold.Click the fastest you can."<<endl;
    		cout <<"3.Get Stone.Click the fastest you can."<<endl;
    		cout <<"4.Get Wood.Click the fastest you can."<<endl;
    		cout <<"5.Stop working."<<endl;
    		cout <<">>";
    		cin >> nation.workforres;
    
    		switch(nation.workforres)
    		{
    		case 1:
    			if (nation.nWorkingFoodVillager == 0)
    			{
    				system("cls");
    				cout <<"There are no villagers that are working for food!Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopworking = false;
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			else if (nation.nWorkingFoodVillager >= 1)
    			{	
    				loopworking = false;
    				nation.getAndIncreaseFood();
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			break;
    		case 2:
    
    			if (nation.nWorkingGoldVillager == 0)
    			{
    				system("cls");
    				cout <<"There are no villagers that are working for gold!Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopworking = false;
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			else if (nation.nWorkingGoldVillager >= 1)
    			{
    				loopworking = false;
    				nation.getAndIncreaseGold();
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			break;
    		case 3:
    
    			if (nation.nWorkingStoneVillager == 0)
    			{
    				system("cls");
    				cout <<"There are no villagers that are working for stone!Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopworking = false;
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			else if(nation.nWorkingStoneVillager >= 1)
    			{
    				loopworking = false;
    				nation.getAndIncreaseStone();
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			break;
    		case 4:
    			if (nation.nWorkingWoodVillager == 0)
    			{
    				system("cls");
    				cout <<"There are no villagers that are working for wood!Press enter to continue..."<<endl;
    				cin.get();
    				cin.get();
    				loopworking = false;
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    
    			else if (nation.nWorkingWoodVillager >= 1)
    			{
    				loopworking = false;
    				nation.getAndIncreaseWood();
    				workshopshow(nation, player, army, villagerdo, armydo, build, upgrader, show);
    			}
    			break;
    		case 5:
    			loopworking = false;
    			show.WhatToDo(nation, player, army, villagerdo, armydo, build, upgrader, *this);
    			break;
    		}
    
    
    
    
    
    
    	}
    
    	return true;
    
    }


    WorkShop.h

    Code:
    //Workshop class
    #include "Nation.h"
    #include "Army.h"
    #include "Player.h"
    #include "Nation.h"
    #include "Show.h"
    #include "Build.h"
    #include "ArmyDo.h"
    #include "VillagerDo.h"
    #include "Upgrader.h"
    
    
    #ifndef WORKSHOP_H
    #define WORKSHOP_H
    
    
    class Nation;
    class Show;
    class VillagerDo;
    class Player;
    class ArmyDo;
    class Build;
    class UpgradDo;
    
    
    class Workshop
    {
    
    public:
    
    	int workshopshow(Nation& nation, const Player& player, Army& army, const VillagerDo& villagerdo, const ArmyDo& armydo,const Build& build, UpgradDo& upgrader, Show show);
    
    
    };
    
    
    
    #endif

    Thank you...You may use this code whenever you want...Comment about it. Thanks!
    Last edited by kevinawad; 06-30-2008 at 05:36 PM.

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    wow
    You couldn't have just attached the .cpp and .h files?

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Since this is a game, I'm moving the thread to the game board.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    57
    Looks great, gonna compile it and try now. Will give suggestions after.

    edit: :O Didn't compile under Code::Blocks 8.02, Windows XP.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,423
    That is quite strange, because it compiles both under VC++ and GCC (via Code::Blocks) for me.
    (Did you forget to pick a compiler?)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    57
    Oh, I think it's because I just opened main.cpp and tried to compile, and in Code::Blocks, you need to have a project to compile multiple files. It's fine once I made a project and added all the files to it. :P
    Whoops. :|
    edit: Bug report!
    If you enter a nation name that has a space in it, such as "lala land", the menu thing kinda starts to glitch up, and you have to get out to play.
    Last edited by michaelp; 06-30-2008 at 01:09 PM. Reason: bug report!

  7. #7
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    If that is your first major programming project than hats off you its very good, and it looks interesting.

    I will say one thing. When you design your classes, unless you really have no other choice, dont delcare normal data members ( like in your nation class ) public. Make them all private. Of course, if you are using arrays, then you will need to make the array size static public like so:

    Code:
    class Foo
    {
    public:
       static const int ARRAY_SIZE = 10;
    
    private:
       int m_theArray[ ARRAY_SIZE ];
    };
    I'm just trying to be a better person - My Name Is Earl

  8. #8
    deletedforumuser
    Guest
    Hello, michaelp, next to the code where it actually save the user response. in main.cpp.

    Actually, when they ask you to write your nation name... use getline..it will accept spaces.

  9. #9
    Registered User
    Join Date
    Nov 2007
    Posts
    57
    Okay.
    BTW, how long have you been programming for? This is pretty good.

  10. #10
    deletedforumuser
    Guest
    i have been programming for a month and a half now(in c++)....well when i was 12..i started and i quited..then i restarted at 13..and did the same thing...now, i cannot give up anymore..because that's what i want to do in my life.

    I learned by myself...im still 15 years old...some people help me very much like Elysia did.
    Last edited by kevinawad; 06-30-2008 at 02:00 PM.

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,407
    A comment on comments: it appears that in many cases you have chosen good variable names, yet you also comment on the variables. For example:
    Code:
    //Create the nation
    Nation nation;
    //Create the player
    Player player;
    //Show
    Show show;
    //Army
    Army army;
    //VillagerDo
    VillagerDo villagerdo;
    //ArmyDo
    ArmyDo armydo;
    //Build
    Build build;
    //Upgrad
    UpgradDo upgrader;
    //Workshop
    Workshop workshop;
    Pretty much all the comments above are unnecessary since the class and variable names provide just as much information. They could even provide misinformation in the event that you change the code but forget to change the comment.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    deletedforumuser
    Guest
    Yes i know, it just added them like that...but, i will just not do it next time.

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Next time please attach the cpp and h files to the post rather than placing the code in the post.

  14. #14
    deletedforumuser
    Guest
    Maximum of 5 cpp files...and check above..there's a link to download.

  15. #15
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Then please remove the code since it just makes your post hard to read and unnecessarily long.

    If you need 2 posts to get all the files in that is fine.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deleting Text from a Text file
    By Daved in forum C++ Programming
    Replies: 5
    Last Post: 11-04-2006, 08:47 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  3. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  4. Text positioning and Text scrolling
    By RealityFusion in forum C++ Programming
    Replies: 3
    Last Post: 08-13-2004, 12:35 AM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21