pallet.cpp

#include "pallet.h" #include <iostream> #include <string> #include <vector> using namespace std; string ItemAtPosition; void Pallet::AddItem(string item) { if (PalletWeight < PalletContent.size()+1) { cout << "You have exceeded the pallet weight." << endl; } else if (PalletWeight > PalletContent.size()) { PalletContent.push_back(item); cout << "The item has been added to the list!" << endl; }; return; } void Pallet::RemoveTopItem() { PalletContent.pop_back(); } void Pallet::GetItemAtPosition(int position) { /*if (PalletContent[position - 1] == test ) { cout << "There is no item at this postion." << endl; } else*/ { cout << "The item at postion " << position << " is " << PalletContent[position - 1] << "." << endl; } }; //need to bug fix when getting item at empty position void Pallet::ListAllItems() { if (PalletContent.size() == 0) { cout << "The list is empty." << endl; } else { for (int i = 0; i < PalletContent.size(); i++) { cout << "Item " << (i + 1) << " :" << PalletContent[i] << endl; } } }; int Pallet::GetCurrentWeight() { return PalletContent.size(); }; int Pallet::GetMaxWeight() { return PalletWeight; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.