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 users 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


media%2F7b7%2F7b7f151a-f8e8-41d2-8bae-42


media%2F6d7%2F6d76e3e0-608e-4c93-bf3c-31

media%2Febe%2Febe55440-3214-45f5-87bc-b2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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(){
on_state = false;
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");
on_state = !on_state;
}
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<<"\nNumber of song titles in the playlist: "<<size;
cout<<" - "<<button_name<<" Button Pressed";
switch(button_name[0]){
  case 'A':
   {
    cout<<"\nA song title is added ";break;
   }
  case 'N':
   {
    cout<<"\nSong "<<(current+1)<<" is Ready.";break;
   }
  case 'B':
   {
    cout<<"\nSong "<<(current+1)<<" is Ready.";break;
   }
  case 'P':
   {
    cout<<"\n"<<(current+1)<<". "<<titles[current];break;
   }
  case 'O':
   {
    if(on_state){
     cout<<"\nConsole is On";
    }else{
     cout<<"\nConsole 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();
}

Add a comment
Know the answer?
Add Answer to:
In this assignment, you will implement a class named KaraokeConsole which mimics the console of a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You will be building a linked list. Make sure to keep track of both the head and tail nodes.

    Ch 8 Program: Playlist (Java)You will be building a linked list. Make sure to keep track of both the head and tail nodes.(1) Create two files to submit.SongEntry.java - Class declarationPlaylist.java - Contains main() methodBuild the SongEntry class per the following specifications. Note: Some methods can initially be method stubs (empty methods), to be completed in later steps.Private fieldsString uniqueID - Initialized to "none" in default constructorstring songName - Initialized to "none" in default constructorstring artistName - Initialized to "none"...

  • cpp Lab Quiz 2 Time Slot: Mon 1-2 PM Deadline: 05/13/2019 2:00 PM Submission: Email Subject: CSC 102 CC3/CC4 LabQuiz 2TS 2 FileType: cpp Write a program to define a music player. Music player has...

    cpp Lab Quiz 2 Time Slot: Mon 1-2 PM Deadline: 05/13/2019 2:00 PM Submission: Email Subject: CSC 102 CC3/CC4 LabQuiz 2TS 2 FileType: cpp Write a program to define a music player. Music player has these features: isPlaying, isStopped, currentSongTitle, nextSong Title, currentSongLength. Programmer can play or stop a song. You can also choose to skip to the next song. Songs are stored in array of strings. When you choose to move to the next song, currentSong Title and nextSongTitle...

  • Introduction In this final programming exercise, you'll get a chance to put together many of the...

    Introduction In this final programming exercise, you'll get a chance to put together many of the techniques used during this semester while incorporating OOP techniques to develop a simple song playlist class. This playlist class allows a user to add, remove and display songs in a playlist. The Base Class, Derived Class and Test Client Unlike the other PAs you completed in zyLabs, for this PA you will be creating THREE Java files in IntelliJ to submit. You will need...

  • Objectives: (You must use loop structures to get credit for this assignment) Students in Norfolk Gardens...

    Objectives: (You must use loop structures to get credit for this assignment) Students in Norfolk Gardens Academy are very excited about the end of year school party. Victoria is playing piano. She is practicing for the end of the school year party every day for a certain amount of time depending on her schedule. It takes her N minutes to practice the first song, and each of following songs takes M minutes longer than the previous song. She has T...

  • Many of us have large digital music collections that are not always very well organized. It...

    Many of us have large digital music collections that are not always very well organized. It would be nice to have a program that would manipulate our music collection based on attributes such as artist, album title, song title, genre, song length, number times played, and rating. For this assignment you will write a basic digital music manager (DMM). Your DMM program must have a text-based interface which allows the user to select from a main menu of options including:...

  • Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named...

    Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...

  • Introduction Welcome to Rad.io, you've been hired to work on our music streaming app, think of...

    Introduction Welcome to Rad.io, you've been hired to work on our music streaming app, think of it as Spotify only more rad! You're in charge of handling our customer’s song list. When a user selects a playlist it will load into the list a number of songs. Users can skip to the next song, move to the previous, they can select a song to play next or select a song to add to the end of their list. Objective You...

  • Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by...

    Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...

  • Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc....

    Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc. needs a program in which the date and temperature in Celsius degrees of an industry laboratory are recorded and stored in a sequential file. In addition, you can see the recorded data and convert the temperatures in the following units: Fahrenheit, Kelvin and Rankine. In addition, they want to see a linear graph that reflects how the temperature has fluctuated day by day, for...

  • This task is a program framework that you should complete. The program should allow the user...

    This task is a program framework that you should complete. The program should allow the user to move a circular figure with the mouse over a drawing area. The current position of the figure is displayed continuously: Given is the main program: import javafx.scene.Scene; import javafx.application.Application; import javafx.beans.value.*; import javafx.scene.*; import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.stage.Stage; public class Main extends Application { private DraggableCircle dc; private Text text; private void updateText() { text.setText("("+dc.getCenterX()+", "+dc.getCenterY()+")"); } @Override public void start(final Stage...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT