Hi! We are doing a team project. My part is to write the function for changing a string of items to separated items and place them in the vector. Also, to write the function for taking them from the vector and changing them back into a string. I am down to 12 errors, but can't seem to get any further. My teammate wants to use a tokenizer, but I couldn't get it to work and tried using an iterator instead. Most of my errors are due to the verbiage in the iterator not being recognized. Can you help?
Heres my code:
//get item number
string getItNum(string ItNumValue)
{
string ItNum = ItNumValue;
return ItNum;
}//end function getitNum
//set size for item number up to 4 chars
void setItNum(string ItNum)
{
string itNum = ItNum;
if (itNum.size() >= 5)
{
itNum.resize(4);
}
}//end function setitNum
//get item name
string getItName(string ItNameValue)
{
string ItName = ItNameValue;
return ItName;
}//end function getItName
//set size for item name up to 12 chars
void setItName(string ItName)
{
string itName = ItName;
if (itName.size() >= 13)
{
itName.resize(12);
}
}//end function setitName
//set size for wholesale price up to 6 chars
void setWhlslPrice(string WhlslPrice)
{
string whlslPrice = WhlslPrice;
if (whlslPrice.size() >= 7)
{
whlslPrice.resize(6);
}
}//end function setwhlslPrice
//get number on hand
string getNumHand(string NumHandValue)
{
string NumHand = NumHandValue;
return NumHand;
}//end function getnumHand
//set size for number on hand up to 4 chars
void setNumHand(string NumHand)
{
string numHand = NumHand;
if (numHand.size() >= 5)
{
numHand.resize(4);
}
}//end function setnumHand
//get max number
string getMaxNum(string MaxNumValue)
{
string MaxNum = MaxNumValue;
return MaxNum;
}//end function getmaxNum
//set size for max number up to 4 chars
void setMaxNum(string MaxNum)
{
string maxNum = MaxNum;
if (maxNum.size() >= 5)
{
maxNum.resize(4);
}
}//end function setmaxNum
//get vendor name
string getVendorName(string VendorNameValue)
{
string VendorName = VendorNameValue;
return VendorName;
}//end function getvendorName
//set size for vendor name up to 16 chars
void setVendorName(string VendorName)
{
string vendorName = VendorName;
if (vendorName.size() >= 17)
{
vendorName.resize(16);
}
}//end function setvendorName
//get reorder number
string getReOrderNum(string ReOrderNumValue)
{
string ReOrderNum = ReOrderNumValue;
return ReOrderNum;
}//end function getreOrderNum
//set size for reOrder number up to 3 chars
void setReOrderNum(string ReOrderNum)
{
string reOrderNum = ReOrderNum;
if (reOrderNum.size() >= 4)
{
reOrderNum.resize(3);
}
}//end function setreOrderNum
//set size for dept name up to 12 chars
void setDeptName(string DeptName)
{
string deptName = DeptName;
if (deptName.size() >= 13)
{
deptName.resize(12);
}
}//end function setdeptName
***********************
Main Project file:
#include "stdafx.h"
#include "item.h"
#include <vector>
using namespace std;
using namespace System;
int main(array<System::String ^> ^args)
{
/****** WHEN THIS BUILDS WITHOUT ERROR SEND IT BACK TO BE TESTED *******/
Console::WriteLine(L"Hello World");
return 0;
}
/*Elizabeth ********************V stringsToItems function V************* DATE */
//returns a vector<item> and takes in a vector<string>
//converts params to proper format before calling the constructor passing in the formated params to create items.
//pushes newly created items onto vector before returning
vector<string> stringsToItems(vector<string> )
{
//split strings into parts
vector<string> myChangingArray;
//tokenizer doesn't work, trying iterator instead
/* //get strings from vector items
for(int x = 0; x < myChangingArray.size(); x++)
{
//tokenizes string into separate items
pkl = strtok(myChangingArray[x], " "); //use for space separate format
while (pkl != NULL)
{
myChangingArray.push_back(pkl);
pkl = strtok(NULL, " ");
}*/
//*************************************
//create new inventory items from variables
item myItem = new item(itNum, itName, whlslPrice, numHand, maxNum, vendorName, reOrderNum, retPrice, deptName);
vector <string>::iterator stringsToItems;
for (stringsToItems = myItem.begin();stringsToItems !=myItem.end();++stringsToItems)
{
stringsToItems.push_back(myItem);//adding the inventory items to the vector
}
//start vector over in new iterator vector
stringsToItems = myItem.begin();
//Cycle forward in vector
++stringsToItems;
++stringsToItems;
//Insert new value in iterator vector
myItem.insert(stringsToItems);
return stringsToItems;//return the vector of items
}
}
//function for changing items to string of items
vector<string> itemsToStrings(stringsToItems)
{
vector<string>stringsToItems;
}