Question
C++ ONLY PLEASE. #######################GIVEN CODE######################## #include Song.h #include Timer.h #include #include using namespace std; //LOOK!! ENTER YOUR FUNCTION PROTOTYPES HERE int main() { Song *mySongArray;
C++ ONLY PLEASE.
#######################GIVEN CODE########################
#include "Song.h"
#include "Timer.h" #include #include using namespace std;
//LOOK!! ENTER YOUR FUNCTION PROTOTYPES HERE
int main() { Song *mySongArray; mySongArray = new Song[150000]; int numSongs = 0; float length; string temp; ofstream outFile; ifstream inFile;
time_t start, end; char filename[50]; cout > filename; inFile.open(filename); if(!inFile) { cout > length; inFile.ignore(); mySongArray[numSongs].setLength(length); numSongs++; } cout
//LOOK! WRITE YOUR INSERTION SORT FUNCTION HERE
//LOOK! WRITE YOUR REVERSE BUBBLE SORT FUNCTION HERE
//LOOK! WRITE YOUR RECURSIVE QUICK SORT FUNCTION HERE
//LOOK! WRITE YOUR PARTITION FUNCTION HERE
##############SONG.H##################################
#ifndef SONG_H #define SONG_H
#include
class Song {
private: string title; string artist; float length;
public: Song() { } Song(string t, string a, float len ) { title = t; artist = a; length = len; }
//***********************ACCESSOR FUNCTIONS*************************** string getTitle() const { return title; } string getArtist() const { return artist; } float getLength() const { return length; } //***********************MUTATOR FUNCTIONS*************************** void setTitle(string t) { title = t; } void setArtist(string a) { artist = a; } void setLength(float len) { length = len; } //***********************OVERLOADED OPERATORS*************************** friend ostream &operator
#endif
#################### TIMER.H AND TIMER.CPP ######################
-------------------TIMER.H------------------------------
#include
time_t getTime(); double totalTime (time_t start, time_t end);
--------------------------TIMER.CPP------------------------------------------------------
#include "Timer.h"
using namespace std;
time_t getTime() { return time(NULL); }
double totalTime (time_t start, time_t end) { return difftime (end, start); }
###############TEST TXT DOCUMENT#####################
Liberty Shane & Shane 6.25 Old Churchyard The Wailin' Jennys 2.20 Tusk Fleetwood Mac 3.37 Happier Marshmello 3.34 Seven Nation Army The White Stripes 3.51
#################SAMPLE OUTPUT####################
Driver.cpp is partially provided for you. This is the file that contains the main function. You will be adding all the necessary programmer-defined functions to Driver.cpp to accomplish the sorting algorithms. You should not have to write or modify code in any of the other given files!! The Song class (Song.h) is provided for you. A Song object has a song title, artist, and length of song (integer). After the sorting algorithm has happened, the song objects should be sorted in increasing order (ascending order) by song title. The Timer class (Timer.h & Timer.cpp) is provided for you. This is the class that is used in the Driver.cpp file to time the algorithms I also have provided a folder of sample sort programs (called Sample Sort Programs) that may be helpful to look at for this lab. You don't have to turn these back in with your lab submission. FIRST TEST - USING 5SONGS.TXT (CONTAINS DATA ON 5 SONGS) You should use 5songs.txt as your input. Make sure 5 Song objects were created (this should print out to the screen). During running of the program three text files should be created. Check to make sure that sortFileInsertion.txt contains the songs in ascending order. sortFileReverseBubble.txt contains the songs in descending order, and sortFileQuick.txt contains the songs in ascending order. If this test works and looks similar to the sample output (probably will be 0 seconds for all three sorts) then you are ready to move on to 130 songs. What is the name of the file with songs? (example.txt) 5songs.txt You have created 5 Song objects. Insertion sort: 0 seconds Reverse bubble sort: 0 seconds Quicksort: 0 seconds Driver.cpp is partially provided for you. This is the file that contains the main function. You will be adding all the necessary programmer-defined functions to Driver.cpp to accomplish the sorting algorithms. You should not have to write or modify code in any of the other given files!! The Song class (Song.h) is provided for you. A Song object has a song title, artist, and length of song (integer). After the sorting algorithm has happened, the song objects should be sorted in increasing order (ascending order) by song title. The Timer class (Timer.h & Timer.cpp) is provided for you. This is the class that is used in the Driver.cpp file to time the algorithms I also have provided a folder of sample sort programs (called Sample Sort Programs) that may be helpful to look at for this lab. You don't have to turn these back in with your lab submission. FIRST TEST - USING 5SONGS.TXT (CONTAINS DATA ON 5 SONGS) You should use 5songs.txt as your input. Make sure 5 Song objects were created (this should print out to the screen). During running of the program three text files should be created. Check to make sure that sortFileInsertion.txt contains the songs in ascending order. sortFileReverseBubble.txt contains the songs in descending order, and sortFileQuick.txt contains the songs in ascending order. If this test works and looks similar to the sample output (probably will be 0 seconds for all three sorts) then you are ready to move on to 130 songs. What is the name of the file with songs? (example.txt) 5songs.txt You have created 5 Song objects. Insertion sort: 0 seconds Reverse bubble sort: 0 seconds Quicksort: 0 seconds
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started