Skip to content
Snippets Groups Projects
Commit 15935722 authored by Steinmaurer, Alexander's avatar Steinmaurer, Alexander
Browse files

code of third vo stream

parents
No related branches found
No related tags found
No related merge requests found
# Ignore all Files
*
# Include all files with extensions (w/o executables) and dirs
!*.*
!*/
# Ignore .vscode directory
.vscode/
\ No newline at end of file
#include <cstdio>
#include <vector>
#include "01-song.hpp"
#include "01-jukebox.hpp"
using std::vector;
using Music::Jukebox;
using Music::Song;
//Möglichkeit 2: Implementierung des Konstruktors erfolgt hier.
// Jukebox::Jukebox(){}
void Jukebox::addSongs(Song* s)
{
songs_.push_back(s);
totalSongs_++;
}
void Jukebox::playNextSong()
{
printf("Playing song: %s from %s\n", songs_.front()->title_, songs_.front()->interpret_);
songs_.pop_back();
}
#ifndef Jukebox_h
#define Jukebox_h
#include <cstdio>
#include <vector>
using std::vector;
namespace Music {
class Song;
class Jukebox {
public:
//Möglichkeit 1: Konstruktor wird hier "implementiert" (jedoch leer)
Jukebox(){}
//Möglichkeit 2: Konstruktor wird hier deklariert, aber in der .cpp implementiert
// Jukebox();
void addSongs(Song* s);
void playNextSong();
private:
vector<Song*> songs_;
int totalSongs_;
};
}
#endif
\ No newline at end of file
#include <cstdio>
#include "01-jukebox.hpp"
#include "01-song.hpp"
using Music::Jukebox;
using Music::Song;
int main()
{
Song s1{"Come and get your love", "Redbone", 3.45};
Song s2{"Up past the nursery", "Suuns", 3.25};
Jukebox j1;
j1.addSongs(&s1);
j1.addSongs(&s2);
j1.playNextSong();
return 0;
}
\ No newline at end of file
#ifndef Song_h
#define Song_h
namespace Music {
class Song {
public:
char title_[50];
char interpret_[50];
float duration_;
};
}
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment