I need big help

Ok so pretty much i have this big project in computer programming in my highschool and have no idea what to do in some parts of my program. I am doing a small text based fighting scene here is some of the code can someone help me with the .cpp file and the header. Im not done yet but i need some help to make sure i'm doing this stuff correctly. It runs and works but i want to make sure everything is being used. If not can someone modify it so that it is and explain why you did what you did?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// FinalProject.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "Player.h"

#include <iostream>

using namespace std;


int main ()
{
	int HP;
	int STM;
	string action;
	string playersName;
	Player1 output;
	

	cout<<"Your name is? ";
	cin>>playersName;
	cout<<"Welcome " <<playersName<<" to my game"<<endl;
	cout<<"Your health is (please enter 100)"<<endl;
	cin>>HP;
	while(HP > 100 || HP < 100)
	{
		cout<<"Please enter 100"<<endl;
		cin>>HP;
	}
	cout<<"Your stamina is (please enter 100)"<<endl;
	cin>>STM;
	while(STM > 100 || STM < 100)
	{
		cout<<"Please enter 100"<<endl;
		cin>>STM;
	}
	cout<<"You have just encountered an enemy."<<endl;
	cout<<"He has 100 health, the objective is to "<<endl;
	cout<<" bring him down to 0 HP using"<<endl; 
	cout<<"the attacks provided. Good luck!!"<<endl;

	//output.playerActions;
	//output.comptuerActions;
that was the cpp file and here is the header
#include <iostream>

#include <string>

using namespace std;

class Player1
{
	private:
		string name;
		int hitPoints;
		int stamina;
		int damage;
		int selection;
	public:
		void playerEntered(string, int, int);
		void playerDisplay();
		void playerActions(int);
};
void Player1::playerEntered(string playersName,int HP, int STM)
{
	name = playersName;
	hitPoints = HP;
	stamina = STM;
}
void Player1::playerDisplay()
{
	cout<< name<<endl;
	cout<<"HP is "<<hitPoints<<endl;
	cout<<"STM is "<<stamina<<endl;
	
}
void Player1::playerActions(int action)
{
	char A = 15;
	char S = 25;
	char D = 35;
	selection = action;
	cout<<" A = Basic attack"
		<<" S = Intermediate attack"
		<<" D = Advanced attack"<<endl;
	cout<<"You have done"<<
	
}
class Computer1
{
	private:
		string name1;
		int hitPoints1;
		int stamina1;
		int damage1;
public:
	void computerDisplay();
	void computerActions();
};



void computerActions(int c, int g)
{
	for(c = 0; g <= 30;)	
g = rand();
	cout<<"The computer has done "<< g <<" damage"<<endl;
};
	
Hi there,
Sorry to say, but this is very sloppy. Some of the code makes very little sense. For instance, why do you ask the user to input their Health and Stamina, when the only accepted input is 100? Is ::playerEntered(string playersName, int HP, int STM) ever used? and ::playerDisplay()? And what is going on in the ::playerActions(int action) method? What about inclusion/macro guards?

I would slap together a quick example of what I would do, but I don't think that would help you. Think about making proper naming conventions for your classes and class methods/members. If you're at all familiar with inheritance, then I would recommend you implement a solution using it.

Unless you have specific questions, we can't really help you.
Last edited on
the thing is that i want to use those but i have no idea how to
Last edited on
Topic archived. No new replies allowed.