File Header comments are used to identify what is in a file, who wrote it, the date it was written, and a description of
Posted: Fri Jul 01, 2022 5:42 am
LinkedList::LinkedList(const LinkedList& rhs){
}
LinkedList::~LinkedList(){
}
const LinkedList& LinkedList::operator=(const LinkedList& rhs){
}
void LinkedList::insertToFront(const ItemType &val){
}
void LinkedList::printList() const{
}
bool LinkedList::get(int i, ItemType& item) const{}
void LinkedList::reverseList(){
}
void LinkedList::printReverse() const{}
void LinkedList::append(const LinkedList &other){
}
void LinkedList::swap(LinkedList &other){
}
int LinkedList::size() const{
}---------------------------------------------#ifndef linkedlist_h#define linkedlist_h
#include <iostream>#include <string>using namespace std;
typedef string ItemType;
struct Node { ItemType value; Node *next;};class LinkedList {private: Node *head;public: // default constructor LinkedList() : head(nullptr) { } // copy constructor LinkedList(const LinkedList& rhs); // Destroys all the dynamically allocated memory // in the list. ~LinkedList(); // assignment operator const LinkedList& operator=(const LinkedList& rhs); // Inserts val at the front of the list void insertToFront(const ItemType &val); // Prints the LinkedList void printList() const; // Sets item to the value at position i in this // LinkedList and return true, returns false if // there is no element i bool get(int i, ItemType& item) const; // Reverses the LinkedList void reverseList(); // Prints the LinkedList in reverse order void printReverse() const; // Appends the values of other onto the end of this LinkedList. void append(const LinkedList &other); // Exchange the contents of this LinkedList with the other one. void swap(LinkedList &other); // Returns the number of items in the Linked List. int size() const; //
};#endif-------------------------------------------------#include <iostream>#include "linkedlist.h"int main(){ LinkedList ls; ls.insertToFront("d"); ls.insertToFront("c"); ls.insertToFront("b"); ls.insertToFront("a"); for (int k = 0; k < ls.size(); k++) { string x; ls.get(k, x); cout << x << endl; // a b c d } LinkedList ls2; ls2.insertToFront("d"); ls2.insertToFront("c"); ls2.insertToFront("b"); ls2.insertToFront("a"); ls2.printList(); //abcd ls2.printReverse(); //dcba LinkedList e1; e1.insertToFront("5"); e1.insertToFront("4"); e1.insertToFront("3"); LinkedList e2; e2.insertToFront("2"); e2.insertToFront("1"); e1.append(e2); // adds contents of e2 to the end of e1 string s; assert(e1.size() == 5 && e1.get(4,s) && s == "2"); LinkedList e3; e3.insertToFront("Sam"); e3.insertToFront("Carla"); e3.insertToFront("Cliff"); e3.insertToFront("Norm"); e3.reverseList(); // reverses the contents of e1 string j; assert(e3.size() == 4 && e3.get(0, j) && j == "Sam"); LinkedList e4; e4.insertToFront("A"); e4.insertToFront("B"); e4.insertToFront("C"); e4.insertToFront("D"); LinkedList e5; e5.insertToFront("X"); e5.insertToFront("Y"); e5.insertToFront("Z"); e5.swap(e4); // exchange contents of e5 and e4 string q; assert(e4.size() == 3 && e4.get(0, q) && q == "Z"); assert(e5.size() == 4 && e5.get(2, q) && q == "B"); LinkedList pls; pls.insertToFront("so"); pls.insertToFront("lmao"); pls.insertToFront("okay"); e4 = pls; e4.printList(); //okay lmao so LinkedList ugh(pls); //copy construct ugh.printList(); //okay lmao so ugh = ugh; //check assigning to self ugh.printList(); //okay lmao so ugh = e5; ugh.reverseList(); ugh.printList(); //a b c d string okay; if(!ugh.get(4, okay)) //to check if it returns false cout << "okay";
ugh.append(pls); ugh.printList(); //a b c d okay lmao so ugh.swap(pls); cout << ugh.size(); //3 ugh.append(ugh); ugh.printList(); //okay lmao so okay lmao so cout << ugh.size() << endl; //6 ugh.append(ugh); string check; ugh.get(8, check); cout << check << endl; //so ugh.printReverse(); //so lmao okay x4}
this is everything that was given. help please
File Header comments are used to identify what is in a file, who wrote it, the date it was written, and a description of what is being solved by the code in the file. All program files should have header comments and it should be located at the TOP of the file! The file header comment details what is in a file. Among other things it should have: 1. The author, date, and course number. 2. A description of what the code in the file accomplishes 3. A list of any modifications (bug fixes) to the file. Note this is not as important for programs written in class, but important in the real world. A good file header comment should fully describe the project and purpose of the code in the file. A programmer (or non- programmer for that matter) should be able to read the file header and be able to understand what is the high level idea and/or purpose behind the code, as well as what data- structures and methods are used. This can save many hours of time getting a new project member up to speed. Function Header comments are used to describe the purpose of a function. Every function must have a separate header comment. Function headers serve to describe the algorithm which the function implements without forcing the reader to interpret code. Further, it serves to visually separate each function (e.g., in C, multiple functions are written in a single file). Short and simple functions can have only a few lines of description. As a rule of thumb, the longer the function the longer the header comment. Remember, always use appropriate amounts of whitespace and good formatting styles. This is as important in coding as in writing technical papers. By using a function header, you will need to use fewer comments in the actual code segment of the function. This will make your program cleaner and more readable. Please follow the comments on the head file (linkedlist.h) to finish the code on the source file (linkedlist.cpp), then run the main file to test your code. linkedlist.cpp linkedlist.h main.cpp