-
Notifications
You must be signed in to change notification settings - Fork 1
/
035_Return_Location.cpp
73 lines (59 loc) · 1.23 KB
/
035_Return_Location.cpp
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
/*
Codewars Coding Challenge
Return location
You are given a class named Person with a method named location, which should return the 3D location of the given person.
Can you find the bug?
class Person
{
public:
Person(int x, int y, int z)
: m_x(x), m_y(y), m_z(z)
{
}
void location(int x, int y, int z)
{
x = m_x;
y = m_y;
z = m_z;
}
private:
int m_x;
int m_y;
int m_z;
};
https://www.codewars.com/kata/57f037927b45ef77b3000260/train/cpp
*/
// My Solution
class Person
{
public:
Person(int x, int y, int z)
: m_x(x), m_y(y), m_z(z)
{
}
void location(int& x, int& y, int& z)
{
x = m_x;
y = m_y;
z = m_z;
}
private:
int m_x;
int m_y;
int m_z;
};
/*
Sample Test
Describe(person_test)
{
It(should_return_location)
{
Person* person = new Person(1, 2, 3);
int x = 0, y = 0, z = 0;
person->location(x, y, z);
Assert::That(x, Equals(1));
Assert::That(y, Equals(2));
Assert::That(z, Equals(3));
}
};
*/