-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSong.cpp
94 lines (78 loc) · 1.92 KB
/
Song.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* Group 2
* Last Updated: 25 Apr 20
* COP 3330
* Group Members:
* Amani Muller
* Eric Lampley
* Zahir Cooper
* Claressa Wilson
* */
#include <iostream>
#include <string>
#include <fstream>
#include <string>
#include "Song.h"
#include <iomanip>
#include <math.h>
using namespace std;
Song::Song()
{
}
Song::Song(string title, string artist)
{
this->title = title;
this->artist = artist;
}
Song::Song(string title, string artist, string album, int length, int year)
{
this->title = title;
this->artist = artist;
this->album = album;
this->length = length;
this->year = year;
}
void Song::set(string title, string artist, string album, int length, int year)
{
this->title = title;
this->artist = artist;
this->album = album;
this->length = length;
this->year = year;
}
bool operator==(const Song& lhs, const Song& rhs)
{
return (lhs.title == rhs.title) && (lhs.artist == rhs.artist);
}
ostream& operator<<(ostream& os, const Song& song)
{
os << song.title << '\n' << song.artist << '\n'
<< song.album << ' ' << "(" << song.year << ")\n" << "Play Time: " << song.length / 60
<< showpoint << fixed << ':'<< setw(2) << left << (song.length % 60) << endl;
return os;
}
ofstream& operator<<(ofstream& os, const Song& song)
{
os << song.title << "," << song.artist << ','
<< song.album << ',' << song.year << ',' << song.length << endl;
return os;
}
istream& operator>>(istream& is, Song& song)
{
cout << "Song Details" << endl;
cout << "Title: ";
is >> song.title;
cout << "Artist: ";
is >> song.artist;
cout << "Album: ";
is >> song.album;
cout << "Year";
is >> song.year;
cout << "Length (in seconds): ";
is >> song.length;
return is;
}
fstream& operator>>(fstream& is, Song& song)
{
is >> song.title >> song.artist >> song.album >> song.year >> song.length;
return is;
}