minecraft_inventory_system.cpp

Displays menue and accepts customers input systemcls

This preview shows page 2 - 4 out of 4 pages.

//displays menue and accepts customers input //system("cls"); display_menu(); cin >> choice; //goes through the list options switch (choice) { case 1: cin.ignore(); system("cls"); display_inventory(inventory, SIZE); break; case 2: system("cls"); search_function(inventory, SIZE); break; case 3: break; } } while (choice < 3); system("pause"); return 0; } //accesses the .txt file for inventory list void get_data(Item inventory[], int SIZE) { ifstream input_file; input_file.open("inventory.txt"); string temp_name; string temp_disc; for (int index = 0; index < SIZE; index++) { getline(input_file, temp_name); getline(input_file, temp_disc); inventory[index].set_item_name(temp_name); inventory[index].set_discription(temp_disc); } input_file.close(); } //sorts the item list void quick_sort(Item inventory[], int start, int end) { //cout << "hello"; int p; if (start < end) { p = partition(inventory, start, end); quick_sort(inventory, start, p-1); quick_sort(inventory, p+1, end);
Image of page 2

Subscribe to view the full document.

} } //partitions the item list int partition(Item inventory[], int start, int end) { Item pivot = inventory[end]; int p_index = start; for (int x = start; x < end; x++) { //cout << "hello"; if (inventory[x].get_item_name() <= pivot.get_item_name()) { swap(inventory[x], inventory[p_index]); p_index++; } }
Image of page 3
Image of page 4
  • Spring '15
  • Guillermo Flores
  • Return statement, Void type, Carriage return, setw

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern