I am having trouble with this part of my program assignment. I have created and compiled the three separate implementation files that design the three classes, they each have a default constructor, overloaded constructor, and a display function.
//************************************************************************************************************
"When your program is working correctly, define an array of pointers to Ship objects to store pointers of up to 15 Ship, CruiseShip or FreightShip objects. Then read in the data from the file pgm8.txt. For each set of ship data it contains a code to indicate whether the data that follows is for a "S"hip, "C"ruise ship or "F"reight ship.
- If the code is "S" then the code is followed by the ship's name and year.
- If the code is "C" then the date of departure, maximum number of passengers and number of passengers signed up for the cruise are also included in the data file.
- If the code is "F" then the code is followed by the ship's name, year and freight capacity.
Use the new operator to create either a Ship, CruiseShip or FreightShip object, storing the pointer to the object in the next element of the array."
I have iincluded my main.cpp file as well as the external file that is to be read in.
//********************************************************************************************************
#include <iostream>
#include <string>
#include <fstream>
#include "pgm8-ship.h"
#include "pgm8-CruiseShip.h"
#include "pgm8-FreightShip.h"
using namespace std;
int main ()
{
/*
Ship ship1("Dauntless", 2003);
CruiseShip cruise1("Titanic", 1912, "4/10/12", 2500, 1324);
FreightShip freight1("Black Pearl", 1800, 50000);
ship1.displayShip();
cout << endl;
cruise1.displayShip();
cout << endl;
freight1.displayShip();
*/
string shipName, departure;
int yearBuilt, maxPass, signPass, capacity;
const int NUM_SIZE = 15;
string code;
Ship *shipObjs[NUM_SIZE];
ifstream infile;
infile.open("pgm8.txt");
while(!infile.eof())
{
}
return 0;
}
External file information:
S
Beagle
1820
C
Carnival Conquest
2002
5/7/2012
2974
1500
F
Aristote
2007
18860
C
Jewel of Seas
2004
5/16/2012
2500
2200
S
Bounty
1789
F
Herodote
2001
25000
C
Crown Princess
2006
5/22/2012
3080
3000
F
Zim Ontario
2009
63300
C
Oasis of Seas
2009
4/5/2012
5400
4800
I would appreciate any help, hints, tips, or suggestions. Thank you!