-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArtist.cpp
More file actions
91 lines (73 loc) · 1.66 KB
/
Copy pathArtist.cpp
File metadata and controls
91 lines (73 loc) · 1.66 KB
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
#include <iostream>
#include <string>
#include "Artist.h"
Artist::Artist() : artist_name("") {}
Artist::Artist(const std::string &a) : artist_name(a)
{
}
Artist::Artist(const Artist &a) : artist_name(a.artist_name)
{
}
void Artist::operator=(const Artist &a)
{
artist_name = a.artist_name;
}
Artist::~Artist()
{
}
bool Artist::operator==(const Artist &a) const
{
return artist_name == a.artist_name;
}
std::ostream &operator<<(std::ostream &out, const Artist &a)
{
out << a.artist_name;
return out;
}
std::istream &operator>>(std::istream &in, Artist &a)
{
std::getline(in, a.artist_name);
return in;
}
void Artist::print() const
{
std::cout << artist_name;
}
Artist *Artist::clone() const
{
return new Artist(*this);
}
FeaturedArtist::FeaturedArtist() : Artist(), featured_artist_name("")
{
}
FeaturedArtist::FeaturedArtist(const Artist &a, std::string fa) : Artist(a), featured_artist_name(fa)
{
}
FeaturedArtist::FeaturedArtist(const FeaturedArtist &fa) : Artist(fa), featured_artist_name(fa.featured_artist_name)
{
}
FeaturedArtist::~FeaturedArtist()
{
}
std::ostream &operator<<(std::ostream &out, const FeaturedArtist &fa)
{
out << fa.featured_artist_name;
return out;
}
void FeaturedArtist::print() const
{
std::cout << artist_name << " (feat. " << featured_artist_name << ")";
}
bool FeaturedArtist::operator==(const Artist &a) const
{
const FeaturedArtist *fa = dynamic_cast<const FeaturedArtist *>(&a);
if (fa)
{
return artist_name == fa->artist_name && featured_artist_name == fa->featured_artist_name;
}
return false;
}
Artist *FeaturedArtist::clone() const
{
return new FeaturedArtist(*this);
}