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

I really do not understand linked lists in c++. The assignment below requires li

ID: 3852978 • Letter: I

Question

I really do not understand linked lists in c++. The assignment below requires linked lists and I'm not sure how to implement them. I could really use some help.

Assignment Your program will create and manage a Guild Roster. It will require the following classes, both of which should be declared in guild.h:

Character: The Character class is a simple class for storing a name and level for characters. It should have a means of retrieving these values after creation, but neither should be mutable.

Roster: The roster class stores Characters in level order—the first is the highest level, the second second highest and so forth. It does this via insertion sort: The order is updated whenever a new character is added. A Roster is initially created with just a name. It should, in addition to adding members, have the ability to print out its roster via a function print. This class must use a linked list to store the Characters. You may need or use other classes. You must implement your own linked list class, not use C++’s standard std::list. You may use the one you may have written in Python has a base (ported to C++) or use the one we may have written in class as a base.

The provided driver file is here:

// driver.cpp

#include <iostream>

#include <string>

#include "guild.h"

using std::cin;

using std::getline;

using std::cout;

using std::endl;

using std::string;

int main()

{

string name;

cout << "What is your guild's name? " << endl;

getline(cin, name);

Roster guild = Roster(name);

string prompt;

do

{

string charName;

cout << "What is the character's name? ";

getline(cin, charName);

int level;

cout << "What is the character's level? ";

cin >> level;

guild.add(Character(charName, level));

cout << "Are there more members (Y/N)? " << endl;

cin.ignore(std::numeric_limits<std::streamsize>::max(), ' '); // Flush newlines

getline(cin, prompt);

} while (prompt[0] == 'y' || prompt[1] == 'Y');

guild.print();

}

Explanation / Answer

// driver.cpp

#include <iostream>

#include <string>

#include "guild.h"

using std::cin;

using std::getline;

using std::cout;

using std::endl;

using std::string;

int main()

{

string name;

cout << "What is your guild's name? " << endl;

getline(cin, name);

Roster guild = Roster(name);

string prompt;

do

{

string charName;

cout << "What is the character's name? ";

getline(cin, charName);

int level;

cout << "What is the character's level? ";

cin >> level;

guild.add(Character(charName, level));

cout << "Are there more members (Y/N)? " << endl;

cin.ignore(std::numeric_limits<std::streamsize>::max(), ' '); // Flush newlines

getline(cin, prompt);

} while (prompt[0] == 'y' || prompt[1] == 'Y');

guild.print();

}