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

I need assistance writing a header file in C++. The file is named guild.h it mus

ID: 3852351 • Letter: I

Question

I need assistance writing a header file in C++. The file is named guild.h it must contain two classes. I need help writing these two classes I will post the description of these two classes below. This must be implemented as a linked list using insertion sort.

(1) 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.

(2) 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 no
Image: Sluggy Freelance (http://www.sluggy.com/comics/archives/daily/080921), Copyright Pete Abrams
members, 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.

Here is a sample execution of what output must look like:

Document anguage: English (U.5.) Change What is your guild's name? Savage Tide What is the character's name? Col Tobinson What is the character's level? 21 Are there more members (Y/N)? y What is the character's name? Lyddie What is the character's level? 20 Are there more members (Y/N)? y What is the character's name? Bin What is the character's level? 20 Are there more members (Y/N)? y What is the character's name? Churtle What is the character's level? 18 Are there more members (Y/N)? y What is the character's name? Roundabout What is the character's level? 19 Are there more members (Y/N)? n Guild Name: Savage Tide Convert Create PDF Comment Combine Files organize Pages aill & Sign Send for Signature Send & Track More Tools Col Tobinson, Level 21 Bin, Level 20 le, Leve Roundabout, Level 19 Churtle, Level 18 Store and share files in the Document Cloud Lean More Type here to search 657 AM 6/26/2017 q:

Explanation / Answer

The guild.h file:

#ifndef _GUILD_
#define _GUILD_
#include <string>
#include <iostream>

using namespace std;

//class Character
class Character
{
   //private variables of the class
   string name;
   int level;

public:

   //default constructor
   Character();

   //paremetrized constructor
   Character(string nam, int l)
   {
       name=nam;
       level=l;
   }

   //function to retrieve the Name
   string returnName()
   {
       return name;  
   }

   //function to retrieve the level
   int returnLevel()
   {
       return level;
   }
};

//Class roaster
class Roaster{

   //instance of class Character
   Character *chara;

   //link to next node
   Roaster *next;

   //default constructor
   Roaster(){}

   //The function to insert into sorted list
   void sortedInsert(Roaster** headRoaster, Roaster* newChar)
   {
    Roaster* temp=new Roaster();

    if (*headRoaster == NULL || (((*headRoaster)->chara->returnLevel()) >= (newChar->chara->returnLevel())))
    {
        newChar->next = *headRoaster;
        *headRoaster = newChar;
    }
    else
    {
        temp = *headRoaster;
        while (temp->next!=NULL &&
               temp->next->chara->returnLevel() < newChar->chara->returnLevel())
        {
            temp = temp->next;
        }
        newChar->next = temp->next;
        temp->next = newChar;
    }
   }

   //function to print the list
   void printList(Roaster *head)
   {
    Roaster *temp = head;
       while(temp != NULL)
       {
           cout<<temp->chara->returnName();
           cout<<" "<<temp->chara->returnLevel()<<endl;
       }
   }

};

#endif

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote