Question
Can you please help me struct void readFile,bool getNextField, and bool getNextField? Data for this code 367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B #include #include #include #include
Can you please help me struct void readFile,bool getNextField, and bool getNextField?
Data for this code
367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B
#include
using namespace std;
// Structure to hold item data struct AISType { string MMSI; // 0 string baseDateTime; // 1 double lattitude; // 2 double longitude; // 3 double sog; // 4 double cog; // 5 double heading; // 6 string vesselName; // 7 string imo; // 8 string callSign; // 9 string vesselType; // 10 string status; // 11 double length; // 12 double width; // 13 double draft; // 14 string cargo; // 15 string transceiverClass; // 16 };
// Prototypes for functions void readFile( ifstream & inFile, vector &item, int& count); bool openInputFile( ifstream & inFile ); string makeStringUpper( string s); int searchForVesselByName( vector & dataBase, string vesselName, vector & s ); void printRecord( AISType & item ); bool getNextField(string &line, int &index, string &subString); double stringConvert(string); int findLastOccurrance(string mmsi, vector &d); int findFirstOccurrance(string mmsi, vector &d); void addUniqueString( vector &s, string value); void saveField( int fieldNumber, string subString, AISType &tempItem ); double distanceTraveled( vector & dataBase, int first, int last );
int main() { // number of records read into the dataBase int count=0;
// the dataBase // vector type is used because it's too big for an array. // (on my computer anyway) vector dataBase; vector mmsi;
// input file ifstream inFile;
// temporary strings string temp; string ansYN;
int found=0; string stars=""; int first =0, last =0;
// open the input file if (openInputFile( inFile ) ) cout
// read the entire file into the dataBase readFile( inFile, dataBase, count);
cout
cin.ignore( 40, ' ');
// user interaction loop do{
// prompt the user for the input to search for. q to quit temp.clear(); mmsi.clear();
cout
// read the user input. getline is used so that spaces may be included // in the input getline(cin, temp, ' ');
// check to see if the user wants to exit the program. // If not exiting, output the search string. if ( temp != "q" or temp == "Q" ){ cout
// search for the number of items that contain the name/phrase // All names in the vessel dataBase are upper case, so make the search // string upper. MMSI is built by the function and contains the vector // of unique vessels that contain the name searched for. found = searchForVesselByName( dataBase, makeStringUpper(temp), mmsi );
// Let the user know if any ships were found with the name if( found
// ships were found, see if the user wants to display them cout > ansYN;
if (ansYN =="y" or ansYN == "Y"){
// print all the first records for the ships found for (unsigned int i=0; i
// find the vessels using MMSI and print the records int index = findFirstOccurrance( mmsi[i], dataBase );
// verify that a valid record was found, print the record if ( index != -1) printRecord( dataBase[index]); } // Ask user if they want to calculate the distance traveled for // the vessel. cout > ansYN;
if ( ansYN == "y" or ansYN == "Y"){ cout > temp; cout
// locate the index value of the first and last record first = findFirstOccurrance( temp, dataBase); last = findLastOccurrance( temp, dataBase);
//output the sitances and miles traveled cout
} while ( true );
} double distanceTraveled( vector & dataBase, int first, int last ){
return 0.0; // Keeps the compiler happy, students should replace
} int findLastOccurrance(string mmsi, vector &d){ return -1; // Keeps the compiler happy, students should replace } int findFirstOccurrance(string mmsi, vector &d){ return -1;// Keeps the compiler happy, students should replace } int searchForVesselByName( vector & dataBase, string vesselName, vector &s) { return 0; // Keeps the compiler happy, students should replace
} void addUniqueString( vector &s, string value){ } double stringConvert(string s){ return 0.0; // Keeps the compiler happy, students should replace } void printRecord( AISType &item ) {
} bool openInputFile( ifstream & inFile ) { return false ; // Keeps the compiler happy, students should replace } void readFile( ifstream & inFile, vector &item, int& count) {
} void saveField( int fieldNumber, string subString, AISType &tempItem ){
} bool getNextField(string &line, int &index, string &subString) { return false;// Keeps the compiler happy, students should replace } string makeStringUpper(string s) { return s; // Keeps the compiler happy, students should replace }
Can you please help me struct void readFile,bool getNextField, and bool getNextField?
Data for this code
367430850,2019-01-01T00:00:05,30.40366,-88.85801,0.0,126.3,511.0,MISS NIZ,IMO8987539,WDF2697,31,0,22,8,2.4,52,B 255806194,2019-01-01T00:00:05,29.91171,-90.10790,0.0,137.2,272.0,NORDBALTIC,IMO9241475,CQAJ8,70,0,207,30,9.4,70,B 548799000,2019-01-01T00:00:06,29.20933,-89.27852,9.5,-78.6,332.0,BOW HECTOR,IMO9363493,DYWK,80,0,174,27,11.0,80,B
void readFile( ifstream & inFile, vectorStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started