Exemple #1
0
int main(int arg, char* argv[])
{
    MovieTree *tree = new MovieTree();
    while(true){
    cout<<"======Main Menu====="<<endl;
    cout<<"1. Find a movie"<<endl;
    cout<<"2. Rent a movie"<<endl;
    cout<<"3. Print the inventory"<<endl;
    cout<<"4. Quit"<<endl;
    string selection;
    cin>>selection;
    if(selection == "1"){
        string title;
        cout<<"Enter movie title"<<endl;
        cin>>title;
        tree->findMovie(title);
    }
    }
Exemple #2
0
int main(int arg, char* argv[])
{
    string a = argv[1];
    MovieTree *tree = new MovieTree(argv[1]);
    while(true){
    cout<<"======Main Menu====="<<endl;
    cout<<"1. Rent a movie"<<endl;
    cout<<"2. Print the inventory"<<endl;
    cout<<"3. Delete a movie"<<endl;
    cout<<"4. Count the movies"<<endl;
    cout<<"5. Quit"<<endl;
    string selection;
    getline(cin, selection);
    if(selection == "1"){
        string title;
        cout<<"Enter movie title"<<endl;
        getline(cin, title);
        tree->rentMovie(title);
    }
    if(selection == "2"){
        tree->printMovieInventory();
    }
    if(selection == "3"){
        string title;
        cout<<"Enter movie title"<<endl;
        getline(cin, title);
        tree->DeleteMovie(title);
    }

    if(selection == "4"){
        tree->countMovies();
    }
    if(selection == "5"){
        cout<<"Goodbye!";
        json_object* output = tree->getJsonObject();
        ofstream myfile;
        myfile.open ("Assignment6Output.txt");
        myfile << json_object_to_json_string_ext(output, JSON_C_TO_STRING_PRETTY);
        myfile.close();
        break;
    }
    }
}
int main(int argc, char* argv[])
{
    MovieTree tree = MovieTree();
    int movrank, movyear, movquant;
    int tick = 0;
    string movtitle, movline, movword, inmov, rinmov, dinmov;

    ifstream filein;
    filein.open(argv[1]);

    if(filein.good())   //  File inout and getlines
    {
        while(getline(filein,movline))
        {
            tick = 0;
            stringstream ss(movline);
            while(getline(ss,movword,','))
            {
                if(tick == 0)
                {
                    movrank = atoi(movword.c_str());
                }
                else if(tick == 1)
                {
                    movtitle = movword;
                }
                else if(tick == 2)
                {
                     movyear = atoi(movword.c_str());
                }
                else if(tick == 3)
                {
                    movquant = atoi(movword.c_str());
                }
                tick = tick+1;

            }
        tree.addMovieNode(movrank, movtitle, movyear, movquant);
        }
    }

    bool proggo = false;

    do  //  main menu
    {
        int minput;
        cout<<"======Main Menu======"<<endl;
        cout<<"1. Find a movie"<<endl;
        cout<<"2. Rent a movie"<<endl;
        cout<<"3. Print the inventory"<< endl;
        cout<<"4. Delete a movie"<<endl;
        cout<<"5. Count the movies"<<endl;
        cout<<"6. Quit"<<endl;

        cin >> minput;

        switch(minput)  //  main switch for menu input
        {
            case 1:
                cout<<"Enter title:"<<endl;
                cin.ignore();
                getline(cin,inmov);
                tree.findMovie(inmov);
                proggo = true;
                break;

            case 2:
                cout<<"Enter title:"<<endl;
                cin.ignore();
                getline(cin,rinmov);
                tree.rentMovie(rinmov);
                proggo = true;
                break;

            case 3:
                tree.printMovieInventory();
                proggo = true;
                break;

            case 4:
                cout<<"Enter title:"<<endl;
                cin.ignore();
                getline(cin,dinmov);
                tree.deleMovie(dinmov);
                proggo = true;
                break;

            case 5:
                cout<<"Tree contains: "<<tree.counMovie()<<" movies."<< endl;
                proggo = true;
                break;

            case 6:
                cout<<"Goodbye!"<<endl;
                tree.DeleteAll();
                exit(0);
                break;

            default:
            proggo = false;
        }
    }
    while(proggo == true);

    //return 0;
}
Exemple #4
0
int main(int argc, char** argv) {
    MovieTree * mt = new MovieTree(argv[1]);
    mt->menu();
    return 0;
}