Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this assignment, you will implement a class named KaraokeConsole which mimics

ID: 3716025 • Letter: I

Question



In this assignment, you will implement a class named KaraokeConsole which mimics the console of a karaoke system. This console allows the user to add a new song title to the playlist, play current song move back to previous song title, and move down to next song title. This console, which can hold a maximum of 10 songs, has five buttons: how each button works On/Off, Next, Back, Play, and Add. The table below shows Device Result of pressing a button On/Off button Turns on the console if it is off; turn off the console if it is on Next button If the current song title is not the final one in the playlist, move forward to the Back button If the current song title is not the first one in the playlist, moves backward to Play buttorn Add button next song title; otherwise, the playlist stays intact. the previous song title; otherwise, the playlist stays intact. Displays the current song title. Adds the new song title to the "end" of the playlist When the console is turned on the first time, it has no song titles saved. If the console is off, pressing any button other than the On/Off button has no effect. Unlike the real console, this console receives a song title from the user's input from the keyboard, plays a song by displaying the song title on the creen, and does not have a pause/stop button. Furthermore, this console does not automatically play songs saved in the console in sequence. In other words, it does not automatically play the next song after playing the current song. To play the next song, the user needs to press the Next button first, then the Play button. To play the previous song, the user has to press the Back button first, then the Play button When a button is pressed, the program performs the proper task and calls the display function of the class to show the result of pressing the button. Each output has two lines: The first line contains the number of song titles in the playlist and which button is pressed. The second line includes the current song title number and the task done The following sample output reflects the usage of the console in sequence

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();
}