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

Please convert the following c++ code into GUI using FLTK. #include <iostream> #

ID: 3587933 • Letter: P

Question

Please convert the following c++ code into GUI using FLTK.

#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Media
{
    private:
        string title;
        string leading_actor;
        string director;
        int copyright;
        string genre;
        string media_type;
        string age_rating;
        int id;
        bool checked_out;
        string patron_name;
        string patron_phone;
    public:
        Media(string title, string leading_actor, string director, int copyright,
                    string genre, string media_type, string age_rating, int id)
        {
           this->title = title;
           this->leading_actor = leading_actor;
           this->director = director;
           this->copyright = copyright;
           this->genre = genre;
           this->media_type = media_type;
           this->age_rating = age_rating;
           this->id = id;
        }          
        void check_out(string patron_name, string patron_phone)
        {
           checked_out = true;
           this->patron_name = patron_name;
           this->patron_phone = patron_phone;
        }
        void check_in()
        {
           checked_out = false;
        }
        bool is_checked_out()
        {
           return checked_out;
        }
        string to_string()
        {
           string output = """ + title + "" ";
           output += "with " + leading_actor + ". Directed by " + director + ". " + std::to_string(copyright);
           output += " (" + genre + "). " + age_rating + ". " + media_type + ". ID: " + std::to_string(id);
           if(is_checked_out())
               output += " Checked out to " + patron_name + " (" + patron_phone + ")";
           return output;  
        }
};

class Video_Store
{
    private:
        vector<Media> publications;
    public:
        void add_media(Media pub)
        {
           publications.push_back(pub);
        }
        void check_out(int media_index, string patron_name, string patron_phone)
        {
           publications[media_index-1].check_out(patron_name, patron_phone);
        }
        void check_in(int media_index)
        {
           publications[media_index-1].check_in();
        }
        string publication_to_string(int media_index)
        {
           return publications[media_index-1].to_string();
        }
        int number_of_media()
        {
           return publications.size();
        }
};

void show_menu()
{
    cout << "=======================================" << endl;
    cout << " Video Rental Management System " << endl;
    cout << "=======================================" << endl;
    cout << "Media" << endl;
    cout << "------------" << endl;
    cout << "(1) Add Media" << endl;
    cout << "(2) List all Media" << endl;
    cout << "(3) Check out Media" << endl;
    cout << "(4) Check in Media " << endl;
    cout << "Utility" << endl;
    cout << "-----------" << endl;
    cout << "(9) Help" << endl;
    cout << "(0) Exit " << endl;
}
int main()
{
    Video_Store videoStore;
    int choice, index, copyright, id;
    string title, leading_actor, director, genre, media_type, age_rating, patron_name, patron_phone;
    show_menu();
    Media *pub;
    while(true)
    {
       cout << "Enter your choice: ";
       cin >> choice;
       switch(choice)
       {
          case 1:   cout << "Enter the title of media: ";
                      cin >> title;
                      cout << "Enter the leading actor for publication: ";
                      cin >> leading_actor;
                      cout << "Enter the director for media: ";
                      cin >> director;
                      cout << "Enter the copyright year for media: ";
                      cin >> copyright;
                      cout << "Enter the genre of media: ";
                      cin >> genre;
                      cout << "Enter the medium of media: ";
                      cin >> media_type;
                      cout << "Enter the age rating of media: ";
                      cin >> age_rating;
                      cout << "Enter the ID for media: ";
                      cin >> id;
                      pub = new Media(title, leading_actor, director, copyright, genre, media_type, age_rating, id);
                      videoStore.add_media(*pub);
                      break;
          case 2:   for(int i = 0; i < videoStore.number_of_media(); i++)
                          cout << videoStore.publication_to_string(i) << endl;
                      break;  
          case 3:   cout << "Enter the index of the media to checkout: ";
                      cin >> index;
                      if(index > videoStore.number_of_media() || index <= 0)
                          cout << "Invalid media index. We have only " << videoStore.number_of_media() << " media." << endl;
                      /*else if(library.publications[index].is_checked_out())  
                          cout << "This publication readily checked out. Can't be granted to you." << endl;
                      */  
                      else
                      {
                         cout << "Enter the name of the patron: ";
                         cin >> patron_name;
                         cout << "Enter the phone number of patron: ";
                         cin >> patron_phone;
                         videoStore.check_out(index, patron_name, patron_phone);
                         cout << videoStore.publication_to_string(index) << endl;
                      }  
                      break;
          case 4:   cout << "Enter the index of the media to checkin: ";
                      cin >> index;
                      if(index > videoStore.number_of_media() || index <= 0)
                          cout << "Invalid media index. We have only " << videoStore.number_of_media() << " media." << endl;
                      /*else if(!(library.publications[index].is_checked_out()))
                          cout << "This publication is not checked out. Can't check-in." << endl;
                      */  
                      else
                          videoStore.check_in(index);
                      break;  
                             
          case 9:   show_menu(); break;  
          case 0:   return 0;
          default:   cout << "Invalid menu. Try again." << endl;
       }
    }
}

Explanation / Answer

#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Media
{
    private:
        string title;
        string leading_actor;
        string director;
        int copyright;
        string genre;
        string media_type;
        string age_rating;
        int id;
        bool checked_out;
        string patron_name;
        string patron_phone;
    public:
        Media(string title, string leading_actor, string director, int copyright,
                    string genre, string media_type, string age_rating, int id)
        {
           this->title = title;
           this->leading_actor = leading_actor;
           this->director = director;
           this->copyright = copyright;
           this->genre = genre;
           this->media_type = media_type;
           this->age_rating = age_rating;
           this->id = id;
        }          
        void check_out(string patron_name, string patron_phone)
        {
           checked_out = true;
           this->patron_name = patron_name;
           this->patron_phone = patron_phone;
        }
        void check_in()
        {
           checked_out = false;
        }
        bool is_checked_out()
        {
           return checked_out;
        }
        string to_string()
        {
           string output = """ + title + "" ";
           output += "with " + leading_actor + ". Directed by " + director + ". " + std::to_string(copyright);
           output += " (" + genre + "). " + age_rating + ". " + media_type + ". ID: " + std::to_string(id);
           if(is_checked_out())
               output += " Checked out to " + patron_name + " (" + patron_phone + ")";
           return output;  
        }
};

class Video_Store
{
    private:
        vector<Media> publications;
    public:
        void add_media(Media pub)
        {
           publications.push_back(pub);
        }
        void check_out(int media_index, string patron_name, string patron_phone)
        {
           publications[media_index-1].check_out(patron_name, patron_phone);
        }
        void check_in(int media_index)
        {
           publications[media_index-1].check_in();
        }
        string publication_to_string(int media_index)
        {
           return publications[media_index-1].to_string();
        }
        int number_of_media()
        {
           return publications.size();
        }
};

void show_menu()
{
    cout << "=======================================" << endl;
    cout << " Video Rental Management System " << endl;
    cout << "=======================================" << endl;
    cout << "Media" << endl;
    cout << "------------" << endl;
    cout << "(1) Add Media" << endl;
    cout << "(2) List all Media" << endl;
    cout << "(3) Check out Media" << endl;
    cout << "(4) Check in Media " << endl;
    cout << "Utility" << endl;
    cout << "-----------" << endl;
    cout << "(9) Help" << endl;
    cout << "(0) Exit " << endl;
}
int main()
{
    Video_Store videoStore;
    int choice, index, copyright, id;
    string title, leading_actor, director, genre, media_type, age_rating, patron_name, patron_phone;
    show_menu();
    Media *pub;
    while(true)
    {
       cout << "Enter your choice: ";
       cin >> choice;
       switch(choice)
       {
          case 1:   cout << "Enter the title of media: ";
                      cin >> title;
                      cout << "Enter the leading actor for publication: ";
                      cin >> leading_actor;
                      cout << "Enter the director for media: ";
                      cin >> director;
                      cout << "Enter the copyright year for media: ";
                      cin >> copyright;
                      cout << "Enter the genre of media: ";
                      cin >> genre;
                      cout << "Enter the medium of media: ";
                      cin >> media_type;
                      cout << "Enter the age rating of media: ";
                      cin >> age_rating;
                      cout << "Enter the ID for media: ";
                      cin >> id;
                      pub = new Media(title, leading_actor, director, copyright, genre, media_type, age_rating, id);
                      videoStore.add_media(*pub);
                      break;
          case 2:   for(int i = 0; i < videoStore.number_of_media(); i++)
                          cout << videoStore.publication_to_string(i) << endl;
                      break;  
          case 3:   cout << "Enter the index of the media to checkout: ";
                      cin >> index;
                      if(index > videoStore.number_of_media() || index <= 0)
                          cout << "Invalid media index. We have only " << videoStore.number_of_media() << " media." << endl;

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