-
Notifications
You must be signed in to change notification settings - Fork 6
/
subject.txt
81 lines (58 loc) · 2.31 KB
/
subject.txt
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
Assignment name : cpp_module_00
Expected files : Warlock.cpp Warlock.hpp
--------------------------------------------------------------------------------
Make a Warlock class. It has to be in Coplien's form.
It has the following private attributes :
* name (string)
* title (string)
Since they're private, you will write the following getters :
* getName, returns a reference to constant string
* getTitle, returns a reference to constant string
Both these functions will have to be callable on a constant Warlock.
Create the following setter:
* setTitle, returns void and takes a reference to constant string
Your Warlock will also have, in addition to whatever's required by Coplien's
form, a constructor that takes, in this order, its name and title. Your Warlock
will not be able to be copied, instantiated by copy, or instantiated without a
name and a title.
For example :
Warlock bob; //Does not compile
Warlock bob("Bob", "the magnificent"); //Compiles
Warlock jim("Jim", "the nauseating"); //Compiles
bob = jim; //Does not compile
Warlock jack(jim); //Does not compile
Upon creation, the Warlock says :
<NAME>: This looks like another boring day.
Of course, whenever we use placeholders like <NAME>, <TITLE>, etc...
in outputs, you will replace them by the appropriate value. Without the < and >.
When he dies, he says:
<NAME>: My job here is done!
Our Warlock must also be able to introduce himself, while boasting with all its
might.
So you will write the following function:
* void introduce() const;
It must display:
<NAME>: I am <NAME>, <TITLE>!
Here's an example of a test main function and its associated output:
int main()
{
Warlock const richard("Richard", "Mistress of Magma");
richard.introduce();
std::cout << richard.getName() << " - " << richard.getTitle() << std::endl;
Warlock* jack = new Warlock("Jack", "the Long");
jack->introduce();
jack->setTitle("the Mighty");
jack->introduce();
delete jack;
return (0);
}
~$ ./a.out | cat -e
Richard: This looks like another boring day.$
Richard: I am Richard, Mistress of Magma!$
Richard - Mistress of Magma$
Jack: This looks like another boring day.$
Jack: I am Jack, the Long!$
Jack: I am Jack, the Mighty!$
Jack: My job here is done!$
Richard: My job here is done!$
~$