0

I am a begineer. I have made a library management system in c++.I want to add gui to it.I am not familiar with much gui apps,but i know Tk library since i am learning c++after python.I have downloaded it from the internet.But i don't know how to add it to path so that g++ compiler can read it.I have also downloaded a boost library because it was written on tk page that it will need it.I have used g++ -I [dir] command but it didn't work for me to add the library to the place where g++ can read it.It is always showing g++.exe: fatal error: no input files.I am on windows.Please also write how to write the path in terminal.I am using mingw compiler for c++.

my code

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

class Library
{
    private:
        vector <string> all_books;//All books in library
        map <string,string> books_lended;//bookname:ownername 
        string email;//Owner email
        string password;//Owner password
        string add_new_book(string);//bookname as input
        string delete_book(string);//Bookname as input
        string booklenderdict();//Return string of dict book_lended
        string allbookslist();//Returns list of allbooks in library
    
    public:
        string library_name;//Name of library.
        vector <string> books_available;//Available books in library
        Library(string , string , string , vector< string > );//Constructor libraryname,email,password,books in library
        string return_book(string,string);//Returns the book
        string book_lend(string,string);//Lends the book
        string admin(string,int,string);
};


Library :: Library(string libraryname, string email1, string password1, vector<string> books){
    /* Sets the variables*/
    
    library_name=libraryname;
    email=email1;
    password=password1;
    books_available=books;
    all_books=books;

}

string Library:: add_new_book(string bookname){

    /*Adds new book to the library
    false-->Book already exists
    true -->Book added
    */
    
    for (auto item : all_books){
        //Checking if the book already exists
        if(item==bookname){
            return "false";
        }
    }
    all_books.push_back(bookname);
    books_available.push_back(bookname);
    return "true";
}

string Library :: delete_book(string bookname){
    /*Deletes the book from the library
    "false"-->book not exists
    "true"--->book deleted
    "null"-->book exists but not available now
    */
    int i=0;
    for(auto item: all_books){
        //Checking if the book exits
        if (item==bookname){
            int k=0;
            for (auto items: books_available){
                //Checking if the book is available
                if (items==bookname){
                    //Deleting the book
                    books_available.erase(books_available.begin()+k);
                    all_books.erase(all_books.begin()+i);
                    return "true";//book deleted
                }k++;
            }return "null";//book currently not availble
        }i++;
    }return "false";//Book not exists
}

string Library :: return_book(string bookname,string borrowername){
    /*Returns the books the user has taken
    true:Boork returnes
    false-->Incorrect book name or book not borrowed
    null-->Owner not correct
    */
    map <string,string>::iterator it;
    for(it=books_lended.begin();it!=books_lended.end();it++){
        //Chcek if the book is being owned
        if(it->first==bookname){
            if(it->second==borrowername){
                //Check if the borrower name is correct
                books_available.push_back(bookname);
                books_lended.erase(bookname);
                return "true";
            }return "null";
        }

    }return "false";
}

string Library :: book_lend(string bookname,string borrowername){
    /*Lend the book
    true:booklended succesfully
    false:Book not availble
    null:book not exists
    */
    int k=0;
    for (auto items:books_available){
        /*Checking if the book is available or not*/
        if (items==bookname){
            books_available.erase(books_available.begin()+k);
            books_lended[bookname]=borrowername;
            return "true";
        }
        
    }
    for (auto item:all_books){
        //Checking if book exists in library
        if(item==bookname){
            return "false";
        }
    }return "null";
}

string Library :: booklenderdict(){
    //Returns string of dictionary of books lended record
    map <string,string>::iterator it;
    string dictionary="{";     
    for(it=books_lended.begin();it!=books_lended.end();it++){
        dictionary.append(it->first);
        dictionary.append(":");
        dictionary.append(it->second);
        dictionary.append(",");
    }
    dictionary.pop_back();
    dictionary.append("}");
    return dictionary;
}


string Library::allbookslist(){
    //Returns string of  list of allbooks in library
    string list="[";
    for (auto item:all_books){
        list.append(item);
        list.append(",");
    }
    list.pop_back();//Removing last comma
    list.append("]");
    return list;
}

string Library :: admin(string password1,int choice,string bookname="k"){
    /*Admin method to return personal details
    following choices are available
    1-->add new book
    2-->delete book
    3-->show email
    4-->return dictionary of borrowers
    5-->return list of books in library
    else return false
    */
    if (password1==password){//Checking if password is correct
        if (choice==1){
            return add_new_book(bookname);
        }
        if (choice==2){
            return delete_book(bookname);
        }
        if(choice==3){
            return email;
        }
        if (choice==4){
            return booklenderdict();
        }
        if (choice==5){
            return allbookslist();
        }
    } 
    return "false";  
}

int main(){
    
    return 0;
}```

0 Answers0