-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathSong.cpp
45 lines (40 loc) · 1.78 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
#include "Song.hpp"
#include <iostream>
#include <iomanip>
Song::Song(std::string songId, std::string title, std::string artist,
std::string album, Genre genre, int durationSeconds,
std::string filePath)
: songId(songId), title(title), artist(artist), album(album),
genre(genre), durationSeconds(durationSeconds), filePath(filePath),
active(true) {}
std::string Song::getSongId() const { return songId; }
std::string Song::getTitle() const { return title; }
std::string Song::getArtist() const { return artist; }
std::string Song::getAlbum() const { return album; }
Genre Song::getGenre() const { return genre; }
int Song::getDurationSeconds() const { return durationSeconds; }
std::string Song::getFilePath() const { return filePath; }
bool Song::isActive() const { return active; }
void Song::setActive(bool status) {
active = status;
}
void Song::displayInfo() const {
std::cout << "Song: " << title << " (ID: " << songId << ")" << std::endl;
std::cout << "Artist: " << artist << std::endl;
std::cout << "Album: " << album << std::endl;
std::cout << "Genre: ";
switch (genre) {
case Genre::POP: std::cout << "Pop"; break;
case Genre::ROCK: std::cout << "Rock"; break;
case Genre::JAZZ: std::cout << "Jazz"; break;
case Genre::CLASSICAL: std::cout << "Classical"; break;
case Genre::HIPHOP: std::cout << "Hip Hop"; break;
case Genre::ELECTRONIC: std::cout << "Electronic"; break;
}
std::cout << std::endl;
int minutes = durationSeconds / 60;
int seconds = durationSeconds % 60;
std::cout << "Duration: " << minutes << ":"
<< std::setfill('0') << std::setw(2) << seconds << std::endl;
std::cout << "Status: " << (active ? "Active" : "Inactive") << std::endl;
}