Description
Following the class diagram shown below, create the class RecordPlayer. An RecordPlayerrepresents a stereo component that can play vinyl records. Please review the class and the sample driver code. 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 recordplayeris turned on. You also can’t return the Needle unless there is actually a record on the player and the recordplayeris 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.
Rules of the record player
- You can affix a platter if the record player is on or off and the needle is not ploped
- Record player must be on and must have record affixed to the platter to plop the needle on the record
- Can only return the needle if the record player is on and there is a record on the player
- Performing the same action twice results in a “no-op” where nothing changes. For example, you can’t plop an already plopped needle, and you can’t return a needle that’s already returned. Another example: you can’t turn on/off a record player that is already on
Please note: codeboard must test differently for this project. There is no input. The provided driver will be called automatically. Your code will not compile when you start the project; only when you’ve implemented the RecordPlayer class will it compile successfully.
Record Player
RecordPlayer( ); void turnOn( ); void turnOff( ); bool isPoweredOn( ); void affixPlatter( string record ); void plopNeedle( ); void returnNeedle( ); bool isOn; string record; bool needleIsOnTheRecord;
Record Player Sample Driver Code
//declare 6 RecordPlayers RecordPlayer good_r, bad_r1, bad_r2, bad_r3, bad_r4, bad_r5; //first test correct good_r.turnOn(); good_r.affixPlatter("Barrow Manila I"); good_r.plopNeedle(); good_r.returnNeedle(); good_r.turnOff(); //bad test, plops needle without turning it on or putting record on bad_r1.plopNeedle(); //turns it on but no record on platter bad_r2.turnOn(); bad_r2.plopNeedle(); //not on nor has album on platter bad_r3.returnNeedle(); //turned on but no album bad_r4.turnOn(); bad_r4.returnNeedle(); //not turned on bad_r5.affixPlatter("Barrow Manila I"); bad_r5.plopNeedle();
Record Player Sample Driver Code Output
Record player is turned on Record Barrow Manila I is now on the platter Needle is placed on the record Needle is returned from the record Record player is turned off Cannot place needle on the record Record player is turned on Cannot place needle on the record Cannot return needle from the record Record player is turned on Cannot return needle from the record Record Barrow Manila I is now on the platter Cannot place needle on the record