Disclaimer this is part of my homework for university. However, I've been trying to solve this problem for the past 9 days and cant seem to be getting anywhere.
The system function as stated below, Staff can 1) Add station (no limitation to how many can be added, station info consists of 4 strings and 1 int that have to be added) 2) View Stations (simply read the station txt file above) 3) Edit stations
The issue I'm currently facing is editing the stations. I would like to do so through the command prompt, I am not sure how exactly this will be accomplished.
void Staff::ManageSelangorRailway()
{
int select;
cout << "Please select one of the following options: \n\n";
cout << "1) Add Station 2) Edit/Delete Station 3) View Station 4) Return";
cin >> select;
switch (select)
{
case 1:
{
vector <StationInfo> getStationInfo;
ofstream out("SelangorStations.txt", ofstream::out | ofstream::app);
char accept = 'y';
char reject = 'n';
while (tolower(accept) == 'y')
{
StationInfo stationInfo = GetStationInfo();
getStationInfo.push_back(stationInfo);
cout << endl;
out << stationInfo;
cout << "Would you like to add another station ? (y/n): ";
if (cin >> accept)
{
out.close();
Staff::Staff();
}
else if (cin >> reject)
{
Staff();
}
}
break;
}
case 2:
{
}
case 3:
{
ifstream file("SelangorStations.txt");
string content;
while (file >> content)
{
cout << content << ' ';
}
}
default:
break;
}
}
No moue movements or clicks. As that would require external knowledge of widget and libraries I've attempted to assign each station added into the vector a unique ID (so far haven't got it working). I'd appreciate it if you or anyone else could actually write out the code to be able to read and replace the stations, at this point I don't mind dropping the unique ID per station idea.
At this point would anyone mind writing out the code. I'm burnt out and would love nothing more then to understand it by actually looking at the code.
What I have tried:
I have tried following several tutorial from YouTube and found similar stack overflow question that addressed this topic. However, it seems that no matter what I do, it just does not seem to work. I have deleted all of my failed attempts (code that did not work). If requested I will share the link that I have used as a point of reference.