Question: C++ Program Unsure how many files needed to create as well. CargoShip, Bubba Gump,1947, 20000 Ship, The Cod Father,1978,0 Cruise Ship, Bullship,1982, 40328 CargoShip, Pug

 C++ Program Unsure how many files needed to create as well."CargoShip", "Bubba Gump","1947", 20000 "Ship", "The Cod Father","1978",0 "Cruise Ship", "Bullship","1982", 40328

"CargoShip", "Pug Boat","2012", 2 "Ship", "Piece of Ship","2008",0 "Cruise Ship", "Yeah Buoy!","1982",

C++ Program

Unsure how many files needed to create as well.

"CargoShip", "Bubba Gump","1947", 20000 "Ship", "The Cod Father","1978",0 "Cruise Ship", "Bullship","1982", 40328 "CargoShip", "Pug Boat","2012", 2 "Ship", "Piece of Ship","2008",0 "Cruise Ship", "Yeah Buoy!","1982", 33236 "Ship", "Unsinkable 11","2002",0 "CargoShip", "Error 404, Fish Not Found", "1971", 404 "CruiseShip", "Sotally Tober","1992",9873 1. Step 1. You need to open the file. 2. Step 2. You have to read a line 3. Step 3. You have to store the results into four strings string shiptype; string shipname; string shipdate; string tonnageCapacityString; int tonnageCapacity: Strip the double quotes off of each token "CargoShip" "Bubba Gump" "1947" 20000 4. Strip the double quotes off of the first three strings 5. Convert the forth string to an integer string shiptype = "CargoShip" string shipname = "Bubba Gump" string shipdate = "1947"; string tonnageCapacityString = "20000"; int tonnageCapacity = 200000; Strip the double quotes off of each token "CargoShip" "Bubba Gump" 1947" 20000 4. Strip the double quotes off of the first three strings 5. Convert the forth string to an integer string shiptype = "CargoShip" string shipname = "Bubba Gump" string shipdate = "1947"; string tonnageCapacityString = "20000"; int tonnageCapacity = 200000; Upload all four files, well documented. while still lines of text! read one line of text grab each of the four tokens and store them in temporary variables strip the quotes off convert the forth one to an integer if (shiptype.compare("Ship") = 0) { // Create a new Ship Object } else if (shiptype.compare("CargoShip") { // Create a new CaragoShip } else { // Create a new Cruise Ship Ship, Cruise Ship and CargoShip Classes Design a Ship class that has the following members: A member variable for the name of the ship (a string) A member variable for the year that the ship was built (a string) A constructor and appropriate accessors and mutators A virtual print function that displays the ship's name and year it was built. Design a Cruise Ship class that is derived from the Ship class. The CruiseShip class should have the following members: . A member variable for the maximum number of passengers (an int) A constructor and appropriate accessors and mutators A print function that overrides the print function in the base class. The Cruise Ship class's print function should display only the ship's name and the maximum number of passengers Design a CargoShip class that si derived from the Ship class. The CargoShip class should have the following members: A member variable for the cargo capacity in tonnage (an int). A constructor and appropriate accessors and mutators A print function that overrides the print function in the base class. The CargoShip class's print function should display only the ship's name and the ship's cargo capacity. Demonstrate the classes in a program that has an array of Ship pointers. Your program will read in a list of Ship, CruiseShip and CargoShip objects from a comma delimited file (see below). The name of that file will be passed in as a command line argument. It will parse each line read and create the appropriate dynamically allocated Ship, cruise Ship or CargoShip objects. The program should then sort the array by the name of the ship. Then the program should step through the array three times, printing just the ships first, then the CargoShip's, then the Cruise Ships. Extra Credit. Modify your sort routine to sort by Ship Type first, then Ship Name. You cannot add any member variables to the classes, so you will have to be able to determine the type another way. If you take this route, you should only have to step through the array once. Comma Delimited File. Note: For a "Ship", the fourth field is not used. The O is included to simplify reading each line of the file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!