Changeset 4

User picture

Author: machiel.sleeuwaert

(2008/10/15 14:12) Over 3 years ago


  

Affected files

Updated week1oplossing/IntLijst.cpp Download diff

34
183
		p << "[" << i << "]= " << m_DynArrPtr[i] << " \n ";
183
		p << "[" << i << "]= " << m_DynArrPtr[i] << " \n ";
184
			
184
			
185
	}
185
	}
186
}
187
188
int& IntLijst::operator[] (int index)
189
{
190
	if (index > m_AantalElementen || index < 0)
191
		
192
		index = 0;
193
	return m_DynArrPtr[index];
194
}
195
196
tstringstream& operator<<(tstringstream& stream, IntLijst& lijst)
197
{
198
	for (int i=0;i<lijst.m_AantalElementen;++i)
199
	{
200
		stream << "[" << i << "]= " << lijst.m_DynArrPtr[i] << " \n ";
201
202
	}
203
	return stream;
204
}
205
tstring operator+(tstring string, IntLijst& lijst)
206
{
207
	tstringstream temp;
208
	temp << string;
209
	temp << lijst;
210
	return temp.str();
186
}
211
}

Updated week1oplossing/IntLijst.h Download diff

34
2
#include "GameEngine.h"
2
#include "GameEngine.h"
3
class IntLijst
3
class IntLijst
4
{
4
{
5
	friend tstringstream& operator<<(tstringstream& stream, IntLijst& lijst);
6
	friend tstring operator+(tstring string, IntLijst& lijst);
7
	
8
5
public:
9
public:
6
	IntLijst();
10
	IntLijst();
7
	
11
	
...
...
30
	bool operator==(const IntLijst& p);
34
	bool operator==(const IntLijst& p);
31
	bool operator!=(const IntLijst& p);
35
	bool operator!=(const IntLijst& p);
32
	void operator>>(tstringstream &p);
36
	void operator>>(tstringstream &p);
37
	int& operator[] (int index);
33
private:	
38
private:	
34
	void vergrootArray();
39
	void vergrootArray();
35
40
...
...
39
44
40
	
45
	
41
};
46
};
47

Updated week1oplossing/vector3.cpp Download diff

34
85
bool Vector3::operator==(const Vector3& p)
85
bool Vector3::operator==(const Vector3& p)
86
{
86
{
87
	return (m_x == p.m_x && m_y == p.m_y && m_z == p.m_z);
87
	return (m_x == p.m_x && m_y == p.m_y && m_z == p.m_z);
88
}
89
90
Vector3 Machiel::operator*(int n, Vector3& p)
91
{
92
	return Vector3(n * p.m_x,n * p.m_y,n * p.m_z);
93
}
94
95
tstringstream& Machiel::operator<<(tstringstream& stream, Vector3& vector3)
96
{
97
	stream << vector3.m_x << "," << vector3.m_y << "," << vector3.m_z; 
98
	return stream;
99
}
100
tstring Machiel::operator+(tstring string, Vector3& vector3)
101
{
102
	tstringstream temp;
103
	temp << string;
104
	temp << vector3;
105
	return temp.str();
88
}
106
}

Updated week1oplossing/vector3.h Download diff

34
4
{
4
{
5
	class Vector3
5
	class Vector3
6
	{
6
	{
7
		
8
7
	public:
9
	public:
8
		// constructoren
10
		// constructoren
9
		Vector3();
11
		Vector3();
...
...
35
		bool operator!=(const Vector3& p);
37
		bool operator!=(const Vector3& p);
36
	private:
38
	private:
37
		float m_x,m_y,m_z;
39
		float m_x,m_y,m_z;
40
41
		friend tstringstream& operator<<(tstringstream& stream, Vector3& vector3);
42
		friend tstring operator+(tstring string, Vector3& vector3);
43
		friend Vector3 operator*(int n, Vector3& vector3);
38
	};
44
	};
45
46
47
48
39
}
49
}
50
51

Updated week1oplossing/Week1Oplossing.cpp Download diff

34
34
34
35
void Week1Oplossing::GameStart()
35
void Week1Oplossing::GameStart()
36
{
36
{
37
	for (int i=0;i<5;++i)
37
	//for (int i=0;i<5;++i)
38
	{
38
	//{
39
		lijst1.push_back(i);
39
	//	lijst1.push_back(i);
40
	}
40
	//}
41
41
42
	for (int i=5;i<10;++i)
42
	//for (int i=5;i<10;++i)
43
	{
43
	//{
44
		lijst2.push_back(i);
44
	//	lijst2.push_back(i);
45
	}
45
	//}
46
46
47
	for (int i=11;i<16;++i)
47
	//for (int i=11;i<16;++i)
48
	{
48
	//{
49
		lijst3.push_back(i);
49
	//	lijst3.push_back(i);
50
	}
50
	//}
51
51
52
	
52
	//
53
	lijst4 = lijst3+lijst2;
53
	//lijst4 = lijst3+lijst2;
54
	lijst4+=lijst1;
54
	//lijst4+=lijst1;
55
55
56
	lijst4 = lijst4;
56
	//lijst4 = lijst4;
57
}
57
}
58
58
59
void Week1Oplossing::GamePaint(RECT rect)
59
void Week1Oplossing::GamePaint(RECT rect)
...
...
70
70
71
	GAME_ENGINE->SetColor(RGB(0,0,0));
71
	GAME_ENGINE->SetColor(RGB(0,0,0));
72
	
72
	
73
tstring temp;
74
temp = _T("lol ");
73
75
74
		
76
	GAME_ENGINE->DrawString(temp+Vector1PTR,100,10+(20*0));
75
		GAME_ENGINE->DrawString(Vector1PTR.ToString(),100,10+(20*0));
76
		GAME_ENGINE->DrawString(Vector2PTR.ToString(),100,10+(20*1));
77
		GAME_ENGINE->DrawString(Vector3PTR.ToString(),100,10+(20*2));
78
		GAME_ENGINE->DrawString(Vector4PTR.ToString(),100,10+(20*3));
79
77
80
		Vector4PTR = Vector1PTR+Vector2PTR;
78
	//	GAME_ENGINE->DrawString(Vector2PTR.ToString(),100,10+(20*1));
81
		GAME_ENGINE->DrawString(Vector4PTR.ToString(),100,10+(20*4));
79
	//	GAME_ENGINE->DrawString(Vector3PTR.ToString(),100,10+(20*2));
82
		Vector4PTR = Vector1PTR + Vector3PTR;
80
	//	GAME_ENGINE->DrawString(Vector4PTR.ToString(),100,10+(20*3));
83
		GAME_ENGINE->DrawString(Vector4PTR.ToString(),100,10+(20*5));
84
81
85
		bool temp = Vector2PTR == Vector3PTR;
82
	//	Vector4PTR = Vector1PTR+Vector2PTR;
86
		tstringstream temph;
83
	//	GAME_ENGINE->DrawString(Vector4PTR.ToString(),100,10+(20*4));
87
		temph << temp;
84
	//	Vector4PTR = Vector1PTR + Vector3PTR;
88
		GAME_ENGINE->DrawString(temph.str(),100,10+(20*6));
85
	//	GAME_ENGINE->DrawString(Vector4PTR.ToString(),100,10+(20*5));
89
		
90
		
91
		temph.str(_T(""));
92
86
93
		temp = Vector2PTR == Vector1PTR;
87
	//	bool temp = Vector2PTR == Vector3PTR;
94
		temph << temp;
88
	//	tstringstream temph;
95
		GAME_ENGINE->DrawString(temph.str(),100,10+(20*7));
89
	//	temph << temp;
96
	
90
	//	GAME_ENGINE->DrawString(temph.str(),100,10+(20*6));
91
	//	
92
	//	
93
	//	temph.str(_T(""));
97
94
95
	//	temp = Vector2PTR == Vector1PTR;
96
	//	temph << temp;
97
	//	GAME_ENGINE->DrawString(temph.str(),100,10+(20*7));
98
	//
98
99
100
99
	
101
	
100
102
101
103