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

C++( record_player) flashdrive Following the class diagram shown below, create t

ID: 3597338 • Letter: C

Question

C++( record_player) flashdrive

Following the class diagram shown below, create the class RecordPlayer. An RecordPlayer represents a stereocomponent that can play vinyl records.. Please review the class and the sample driver code. As explained in class, there is a specific order to the way the class methods should be called. In other words, you can't plop the Needle unless there actually is a record on the player and the recordplayer is turned on. You also can't return the Needle unless there is actually a record on the player and the recordplayer is turned on. Your class should enforce these rules and write errors to cout as they occur. A sample driver for this class is shown below. You should probably make a more thorough driver to test your class better.

Your submission should follow this organization:

main.cpp this is your driver file

record_player.h

record_player.cpp

RecordPlayer

void turnOn( );
void turnOff( );
bool isPoweredOn( );
void affixPlatter( string record );
void plopNeedle( );
void returnNeedle( );

Sample Driver Code

RecordPlayer r;
r.turnOn();
r.affixPlatter( "Barry Manilow I" );
r.plopNeedle( );
r.returnNeedle( );
r.turnOff( );

cout << "--Test 2--" << endl;

RecordPlayer badr;
badr.plopNeedle( );

cout << "--Test 3--" << endl;

RecordPlayer badr1;
badr1.turnOn( );
badr1.plopNeedle( );

cout << "--Test 4--" << endl;

RecordPlayer badr2;
badr2.returnNeedle( );

cout << "--Test 5--" << endl;

RecordPlayer badr3;
badr3.turnOn( );
badr3.returnNeedle( );

Sample Driver Output

RecordPlayer

RecordPlayer( );

void turnOn( );
void turnOff( );
bool isPoweredOn( );
void affixPlatter( string record );
void plopNeedle( );
void returnNeedle( );

bool my_isOn;
string my_Record;
bool my_NeedleIsOnTheRecord;

Sample Driver Code

cout << "--Test 1--" << endl;

RecordPlayer r;
r.turnOn();
r.affixPlatter( "Barry Manilow I" );
r.plopNeedle( );
r.returnNeedle( );
r.turnOff( );

cout << "--Test 2--" << endl;

RecordPlayer badr;
badr.plopNeedle( );

cout << "--Test 3--" << endl;

RecordPlayer badr1;
badr1.turnOn( );
badr1.plopNeedle( );

cout << "--Test 4--" << endl;

RecordPlayer badr2;
badr2.returnNeedle( );

cout << "--Test 5--" << endl;

RecordPlayer badr3;
badr3.turnOn( );
badr3.returnNeedle( );

Sample Driver Output

--Test 1--
recordplayer is on...
recordplayer has album Barry Manilow I
recordplayer is playing album Barry Manilow I
recordplayer has stopped playing album
recordplayer is off...
--Test 2--
you can't plop the needle without being powered on!
--Test 3--
you can't plop the needle without an album!
--Test 4--
you can't return the needle without being powered on!
--Test 5--
you can't return the needle without an album!

Explanation / Answer

class RecordPlayer

{

//private:

bool my_isOn;

string my_Record;

bool my_NeedleIsOnTheRecord;

/*public:

void turnOn( );

void turnOff( );

bool isPoweredOn( );

void affixPlatter( string record );

void plopNeedle( );

void returnNeedle( );

*/

public:

RecordPlayer()

{

my_isOn = false;

my_Record = "";

my_NeedleIsOnTheRecord=false;

}

void turnOn()

{

if(my_isOn == false)

{

if(isPoweredOn() == true)

{

my_isOn = true;

cout<<"recordplayer is on..."<<endl;

}

}

}

void turnOff( )

{

if(my_isOn == true)

{

cout<<"recordplayer is off..."<<endl;

my_isOn = false;

}

}

bool isPoweredOn( )

{

//turn on the record player and return true

return true;

}

void affixPlatter(string record)

{

cout<<"record player has album "<<record<<endl;

my_Record = record;

}

void plopNeedle()

{

//if(my_NeedleIsOnTheRecord == false)

{

if(my_isOn == true)

{

if(my_Record != "")

{

cout<<"recordplayer is playing album "<<my_Record<<endl;

my_NeedleIsOnTheRecord = true;

}

else

{

cout<<"you can't plop the needle without an album!"<<endl;

}

}

else

{

cout<<"you can't plop the needle without being powered on!"<<endl;

}

}

}

void returnNeedle()

{

//if(my_NeedleIsOnTheRecord == true)

{

if(my_isOn == true)

{

if(my_Record != "")

{

cout<<"recordplayer is playing album "<<my_Record<<endl;

my_NeedleIsOnTheRecord = false;

}

else

{

cout<<"you can't return the needle without an album"<<endl;

}

}

else

{

cout<<"you can't return the needle without being powered on!"<<endl;

}

}

}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote