Damo, your implode function isn't working

Invalid arguments passed in [path]/includes/functions_post_groans.php on line 193

Actually it looks like it's a problem with groans. But I still find it funny that you named a function "implode".
 
I'm going to show off my 1337 coding skills right now:

#include <iostream>
#include <fstream>
#include <string>

#include <list>
#include <algorithm>
#include <queue>

#include "Student.h"

using namespace std;

void insert(list<student> &classReg, student &addStudent)
{
if(classReg.empty() == true) //if there's no one in the list, put addStudent at the beginning
{
classReg.insert(classReg.begin(), addStudent);
}
else
{
list<student>::iterator addIt;
addIt = classReg.begin(); //point iterator to beginning of list

while(addIt != classReg.end() && *addIt != addStudent && addStudent > *addIt) //traverse the list with the iterator until it reaches
{ //a student who addStudent comes before in alphabetical order,
addIt++; //or reaches one of several special cases
}
if(addIt == classReg.end()) //if loop reached the end of the list, put addStudent at the end
{ //(May seem redundant, but this is to avoid errors when I dereference addIt below)
classReg.insert(classReg.end(), addStudent);
}
else if(*addIt == addStudent) //if addStudent is already in the class, display an error
{
cout << addStudent.ID << " " << addStudent.name << " is already enrolled in the class. " <<endl;
}
else //else, add them before the student they come before in alphabetical order
{
classReg.insert(addIt, addStudent);
}
}
}

void main()
{
int maxSize;

ifstream infile;
infile.open("Data1.txt",ios::in);

if (!infile)
cout << "Not a file." << endl;
else
{
list<student> classReg;
deque<student> wait;


while(infile.eof()!=true)
{
string transType;
infile >> transType;

if(transType=="setMax")
{
infile >> maxSize;
}

else if (transType == "drop")
{
int studentID;

infile >> studentID;

student dropStudent;
dropStudent.name = "NULL";
dropStudent.ID = studentID;

list<student>::iterator dropIt;

dropIt = find(classReg.begin(), classReg.end(), dropStudent); //makes dropIt point to the student in question

if(dropIt == classReg.end()) //if nothing is found, send an error.
{
cout << "Cannot drop class because " << studentID << " is not enrolled." << endl;
}
else
{
classReg.erase(dropIt);
if(wait.empty() != true)
{
student waitStudent;
waitStudent = wait.front();

insert(classReg, waitStudent); //insert the person at the front of the queue into the list
cout << waitStudent.ID << " " << waitStudent.name<< " has been removed from waiting list and enrolled in class."<<endl;
wait.pop_back(); //remove them from the queue
}
}
}

else if (transType == "add")
{
student addStudent;
infile >> addStudent.ID;

string Name;
string lastName;
infile >> Name;
infile >> lastName;
Name.append(" ");
Name.append(lastName);

addStudent.name = Name;

if(classReg.size() > maxSize) //if list is larger than the maximum size push the addStudent to the waiting queue
{
wait.push_front(addStudent);

cout << "Class is full; student " << addStudent.ID << " " << addStudent.name << " has been added to waiting list." << endl;
}
else
{
insert(classReg, addStudent);
}

}

else if (transType == "printRoll")
{
if(classReg.empty() == true)
{
cout << "Class roll: No students enrolled at this time." << endl;
}
else
{
list<student>::iterator printIt;
for(printIt = classReg.begin(); printIt != classReg.end(); printIt++)
{
student printStudent;
printStudent = *printIt;
cout << printStudent.ID << " " << printStudent.name << endl;
}
}
}

else if (transType == "printWait")
{
if(wait.empty() == true)
{
cout<<" Waiting list is currently empty."<<endl;
}
else
{
deque<student>::iterator printIt;
for(printIt = wait.begin(); printIt != wait.end(); printIt++)
{
student printStudent;
printStudent = *printIt;
cout << printStudent.ID << " " << printStudent.name << endl;
}
}
}
}
}

system("pause");
}



Took me 6 hours to complete. And it's still buggy. I imagine that if anyone has experience in C++ coding, they're going to quote this and make fun of me.
 
I'd say "what's the point?" But considering that Watermark lives in the Biloxi-Gulfport area of MS, Detroit might actually be a step-up/vacation spot for him...
 
If you like shitty, run-down places, I'm sure that Detroit is perfect for you. What's the difference between 8 Mile and the rest of the dump?
 
If you like shitty, run-down places, I'm sure that Detroit is perfect for you. What's the difference between 8 Mile and the rest of the dump?
Says someone whose never been. My lil stretch of 8 mile is... ok. It isn't great, mainly because it's boring. Mostly car dealers and some light industry/light commercial stuff. A few bars, but they're not my kinda place. Go up to 9 mile, and everything is tits. Well, except at Grosebeck, but that's because it's a road with nothing but contractor shops.
 
Back
Top