Question
Can somebody solve the TODO parts of the following problem. Thanks Description This assignment builds on top of the ListNode class designed and tested in
Can somebody solve the TODO parts of the following problem.
Thanks
Description
This assignment builds on top of the ListNode class designed and tested in Assignment 4 where constructionand testing of the ListNode class has already been done. Recall that a ListNode object contains a data field and a pointer to the next ListNode object.
We now encapsulate the functions to create, search and update the database into a LinkedList class. There are two members in this class. A pointer called front that points to a ListNode object and an integer count of the total number of objects currently in the list.
As before, we are not going to use pre-fabricated classes from the c++ library, but construct the LinkedList ADT from scratch.
We can now use this class to create a LinkedList object which contains a collection of ListNodes each having a Song object in the data field. The api is put through its paces by initially testing it on a dummy database containing four songs. The main program then repeats the testing process with the song list in the file SongData.txt and then again with the song list in the file SongDataDouble.txt.
The number of steps taken to populate the database for both files is recorded.
Instruction
#This assignment requires you to
Read the Assignment 5 Notes
Watch the Assignment 5 Support video
Implement the following methods of the LinkedList class
-custom constructor
-setters for next pointer and data
Implement the insert, remove and get method in the LinkedListcpp.h file
Scan the given template to find the above //TODO and implement the code needed
//Requires: Song for inserting
//Effects: creates a new ListNode with input value and inserts in proper position (increasing order of chart position)in the chain. If LinkedList, adds to the beginning
//Modifies: front, if node is added at the beginning.
//Also changes the next pointer of the previous node to point to the newly inserted list node. the next pointer of the newly inserted pointer points to what was the next of the previous node. This way both previous and current links are adjusted
//TODO
template
int LinkedList
int steps=0;
//TODO
return steps;
}
//Requires: Song title for searching
//Effects: traverses the LinkedList (database) starting from front until the end comparing titles Returns the original search value if found otherwise returns an empty song with blank title
//Modifies: Nothing
//TODO
template
T LinkedList
ListNode
//TODO
return current->getData();
}
//TODO
template
int LinkedList
//TODO
int steps=0;
return steps;
}
/ /Requires: index position of Song to be found
//Effects: traverses the LinkedList starting from front and travels to the index position (if valid) and returns the song at that index position. Note index position may NOT be the same as chart position
//Modifies: Nothing
//TODO
template
T LinkedList
ListNode
//TODO
return current->getData();
}
Guidance
# The driver is given LinkedListMain.cpp is given to you that does the following tests
Calls a method testDummyData that creates a LinkedList type database to hold four songs. It tests the api by adding, removing, inserting and searching for songs. It also prints the database..
Creates an object called database of type LinkedList to hold object of Song type.
Constructs a SortBy function object and sets search by title to true in the constructor
Calls the populateDatabase method to read songs from the SongData file and insert into the database using title as search key
. It tests the api by adding, removing and inserting (from different positions) and searching for existing and missing songs. It also prints the database.
Todo List:
Use the templates given to you. You are not obliged to use my template. You may modify it as needed. for
Code marked GIVEN CODE is given to you for free
You are also given a makefile if needed
Comments marked //TODO indicated you need to fill in code.
These templates are a guide and you may tweak them if needed
Run and test the project for edge cases, average and load cases
Your output must exactly match the output.txt given to you You may run the program on the college server, OR on your
Personal platform (Visual Studio, Xcode, Replit)
Take screen shots of the output, paste them into a MS word file or direct your output to a textfile and copy this into your document
#include "ListNodecpp.h" #include "SortBycpp.h" #include
private: ListNode
public: LinkedList
};
#include "LinkedList.h"
//GIVEN template
//TODO
template
//Requires: index position of Song to be found //Effects: traverses the LinkedList starting from front and travels to the index position (if valid) and returns the song at that index position. Note index position may NOT be the same as chart position //Modifies: Nothing //TODO template
#include
//template
// post: constructs a node with data 0 and null link public: ListNode(); public: ListNode(T data); public: ListNode(T idata, ListNode
#include "ListNode.h" template
#include
#include "Song.h" Song::Song(){ title=""; singer=""; chartPosition=0; } Song::Song(std::string title, std::string singer, int chartPosition){ this->title=title; this->singer=singer; this->chartPosition=chartPosition; } std::string Song::toString(){ return "Title: "+title+ " Singer: "+singer+ " ChartPosition: "+std::to_string(chartPosition); } // std::ostream& operator<<(std::ostream & str, Song *s){ str<< s->toString(); return str; } int Song::getChartPosition(){ return chartPosition; } void Song::setChartPosition(int pos){ chartPosition=pos; } void Song::setTitle(std::string newTitle){ title=newTitle; } void Song::setSinger(std::string newSinger){ singer=newSinger; } bool Song::operator<(Song b){ return chartPosition
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