In this assignment, you will implement a class named KaraokeConsole which mimics
ID: 3716025 • Letter: I
Question
Explanation / Answer
here is your program : --------->>>>>>>>>>>
KaraokeConsole.h : ------->>>
#ifndef KARAOKECONSOLE_CLASS_
#define KARAOKECONSOLE_CLASS_
#include<iostream>
using namespace std;
const int MAX_SONG_TITLES = 10;
const int MAX_SIZE = 15;
class KaraokeConsole{
private:
bool on_state;
string titles[MAX_SONG_TITLES];
int size;
int current;
char button_name[MAX_SIZE];
public:
KaraokeConsole();
void onOffPressed();
void nextPressed();
void backPressed();
void playPressed();
void addPressed(string);
bool isOn();
void display();
};
#endif
KaraokeConsole.cpp : -------->>>>>>>>>
#include "KaraokeConsole.h"
#include<cstring>
KaraokeConsole::KaraokeConsole(){
> size = 0;
current = -1;
strcpy(button_name," ");
for(int i = 0;i<MAX_SONG_TITLES;i++){
titles[i] = " ";
}
}
void KaraokeConsole::backPressed(){
strcpy(button_name,"Back");
if(current <= 0){
return;
}
current--;
}
void KaraokeConsole::nextPressed(){
strcpy(button_name,"Next");
if(current >= size-1){
return;
}
current++;
}
void KaraokeConsole::onOffPressed(){
strcpy(button_name,"On/Off");
> }
void KaraokeConsole::playPressed(){
strcpy(button_name,"Play");
if(on_state){
display();
}
}
void KaraokeConsole::addPressed(string title){
strcpy(button_name,"Add");
if(size >= MAX_SONG_TITLES){
return;
}
titles[size++] = title;
}
void KaraokeConsole::display(){
cout<<" Number of song titles in the playlist: "<<size;
cout<<" - "<<button_name<<" Button Pressed";
switch(button_name[0]){
case 'A':
{
cout<<" A song title is added ";break;
}
case 'N':
{
cout<<" Song "<<(current+1)<<" is Ready.";break;
}
case 'B':
{
cout<<" Song "<<(current+1)<<" is Ready.";break;
}
case 'P':
{
cout<<" "<<(current+1)<<". "<<titles[current];break;
}
case 'O':
{
if(on_state){
cout<<" Console is On";
}else{
cout<<" Console is Off";
}
}
}
}
int main(){
KaraokeConsole st;
st.addPressed("Rakhi");
st.display();
st.addPressed("lonawala");
st.addPressed("deepika");
st.nextPressed();
st.nextPressed();
st.display();
st.playPressed();
st.display();
st.onOffPressed();
st.playPressed();
st.display();
st.backPressed();
st.display();
}