1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include "Student.h"
#include <iostream>
#include <sstream>
#include <string>
//#include <new>
using namespace std;
Student::Student()
{
x = 0;
} //end null constructor
Student::Student(int a, string b)
{
x = a;
tempo = b;
} //end constructor
Student::~Student()
{
//dtor
}
void Student::fname(size_t pos, int pos_three, string fnames[],char de)
{
pos = 0;
pos = Student::tempo.find(de);
if (pos!=string::npos) //If we find this | character...
{
pos_three = pos; //...we store its position to an integer array,which is a guide for the selection of the last names.
} //end if
string first_name= Student::tempo.substr (0, pos_three); //Extracting the substring data...
fnames[x] = first_name; //...and now we store the extracted data to the fnames array for the bubble sort...
//Student::first_array = Student::fnames[x]; //dumping the private array to a public one...
Student::tempo.erase (0,pos_three+1); //and erase those entries from the data array.
} //end fname
void Student::setfirstnames()
{
void fname(size_t temp, int pos_one, string firstnames[], '|');
instructions[x] = x; //put the integers in the guide array
} //end setfirstnames
void Student::setlastnames()
{
void fname(size_t temp, int pos_one, string lastnames[], '|');
} //end setlastnames
void Student::setGPA() {
void fname(size_t temp, int pos_one, string G_array[], '|');
//dumping the contents of the string array to the float array...
stringstream(G_array[x])>>GPAs[x];
} //end setGPA
void Student::setcredits() {
void fname(size_t temp, int pos_one, string cr_array[], '|');
stringstream(cr_array[x])>>credits[x];
} //end setcredits
string Student::getfirstnames()
{
//Remember that this should return the values...
} //end getfirstnames
string Student::getlastnames()
{
} //end getlastnames
string Student::getGPA()
//Before we can start bubble sort, we must define the sswap() function:
string Student::sswap(string * first, string * second) {
int temptwo;
temptwo = *first;
*first = *second;
*second = temptwo;
} //end sswap
string Student::mastersort(){
//Let the bubble sort begin!
string lnames[50],last_array[50];
for (int b = 0; b < 50; b++)
{
for (int c = 0; c < 50; c++)
{
if (lnames[c]> lnames[c+1])
{
sswap(lnames[c], lnames[c+1]);
//We might want to make an integer array that gets sorted, so that the instructions for the rearranging
//of other arrays get created.
} //end if
} //end inner for
//This string variable must accept 50 entries...
last_array[b] = lnames[b]; //or we could dump the private array to a public array...
} //end outer for
} //end mastersort
|