C++ Assignment need to done in 4 hours

profilechenponlineassighmenthelp
Newfolder211.zip

New folder (2)/central.cpp

New folder (2)/central.cpp

int  main (   )
{
   SV_VEC sVec ;

   run (  sVec  );

}

/*
 * The user is asked for the name of an input text file
 * If this file exists, then the contents of the file are
 * read into the vector, then the file is closed.
 *
 */
void  load (  SV_VEC &  sVec  )
{

}

void  run (  SV_VEC &  sVec  )
{
    load (  sVec  );
     int  choice  =   - 1 ;

     while (  choice  !=   static_cast <   int > (  MAIN :: EXIT  )   )
     {
         display (   );
         std :: cout  <<   "Enter choice >> " ;
         std :: cin  >>  choice ;
         std :: cin . ignore (   100000 ,   '\n'   );
         std :: cout  <<  std :: endl ;
         process (  sVec ,  choice  );
     }
}

void  display (   )
{
    std :: cout  <<   "CENTRAL SPACEWAYS MAIN MENU"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( MAIN :: ADD_SPACE_VEHICLE )
          <<   ". Add Menu"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( MAIN :: DISPLAY )
          <<   ". Display Menu"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( MAIN :: SAVE )
          <<   ". Save "   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( MAIN :: EXIT )
          <<   ". Exit"   <<  std :: endl ;
}

void  process (  SV_VEC &  sVec ,   int  choice  )
{
     switch (  choice  )
     {
          case   static_cast < int > ( MAIN :: ADD_SPACE_VEHICLE )   :
              add (  sVec  );
            break ;

          case   static_cast < int > ( MAIN :: DISPLAY )   :
              displayOptions (  sVec  );
            break ;

          case   static_cast < int > ( MAIN :: SAVE )   :
              save (  sVec  );
            break ;

          case   static_cast < int > ( MAIN :: EXIT )   :
               // just trap this choice so that it does not show
               // as an error
            break ;

          default :
              std :: cout  <<   "That is not a valid choice"   <<  std :: endl ;
            break ;
     }
}


void  add (  SV_VEC &  sVec  )
{

     int  choice  =   - 1 ;

     while (  choice  !=   static_cast <   int > (  ADD :: EXIT  )   )
     {
         displayAddOptions (   );
         std :: cout  <<   "Enter choice >> " ;
         std :: cin  >>  choice ;
         std :: cin . ignore (   100000 ,   '\n'   );
         std :: cout  <<  std :: endl ;
         processAdd (  sVec ,  choice  );
     }
}

void  displayAddOptions (   )
{
    std :: cout  <<   "CENTRAL SPACEWAYS ADD MENU"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( ADD :: FREIGHT )
          <<   ". Add Freight Vehicle"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( ADD :: PASSENGER )
          <<   ". Add Passenger Vehicle"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( ADD :: MODULE )
          <<   ". Add Module"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( ADD :: GUEST )
          <<   ". Add Guest"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( ADD :: EXIT )
          <<   ". Return to main menu"   <<  std :: endl ;

}

void  processAdd (  SV_VEC &  sVec ,   int  choice  )
{
     switch (  choice  )
     {
          case   static_cast < int > ( ADD :: FREIGHT )   :
              addFreight (  sVec  );
            break ;

          case   static_cast < int > ( ADD :: PASSENGER )   :
              addPassenger (  sVec  );
            break ;

          case   static_cast < int > ( ADD :: MODULE )   :
              addModule (  sVec  );
            break ;

          case   static_cast < int > ( ADD :: GUEST )   :
              addGuest (  sVec  );
            break ;

          case   static_cast < int > ( ADD :: EXIT )   :
               // just trap this choice so that it does not show
               // as an error
            break ;

          default :
              std :: cout  <<   "That is not a valid choice"   <<  std :: endl ;
            break ;
     }

}

/*
 * This just adds a new Freight vehicle from the keyboard,
 * it does not add any Modules
 *
 */

void  addFreight (  SV_VEC &  sVec  )
{

}

/*
 * This just adds a Passenger Vehicle from the keyboard,
 * it does not add any Guests
 *
 */
void  addPassenger (  SV_VEC &  sVec  )
{

}

void  addModule (  SV_VEC &  sVec  )
{

}

void  addGuest (  SV_VEC &  sVec  )
{

}

void  save (   const  SV_VEC &  sVec  )
{

}


void  displayOptions (   const  SV_VEC &  sVec  )
{
     int  choice  =   - 1 ;

     while (  choice  !=   static_cast <   int > (  DISPLAY :: EXIT  )   )
     {
         displayMenuOptions (   );
         std :: cout  <<   "Enter choice >> " ;
         std :: cin  >>  choice ;
         std :: cin . ignore (   100000 ,   '\n'   );
         std :: cout  <<  std :: endl ;
         processDisplay (  sVec ,  choice  );
     }

}

void  displayMenuOptions (   )
{
    std :: cout  <<   "CENTRAL SPACEWAYS DISPLAY MENU"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( DISPLAY :: ALL )
          <<   ". Display All"   <<  std :: endl ;
    std :: cout  <<   "\t"   <<   static_cast < int > ( DISPLAY :: EXIT )
          <<   ". Return to main menu"   <<  std :: endl ;

}

void  processDisplay (   const  SV_VEC &  sVec ,   int  choice  )
{
     switch (  choice  )
     {
          case   static_cast < int > ( DISPLAY :: ALL )   :
              displayAll (  sVec  );
            break ;

          case   static_cast < int > ( DISPLAY :: EXIT )   :
               // just trap this choice so that it does not show
               // as an error
            break ;

          default :
 std :: cout  <<   "That is not a valid choice"   <<  std :: endl ;
            break ;
     }

}

void  displayAll (   const  SV_VEC &  sVec  )
{

}
         

New folder (2)/central.h

#include "freight.h" #include "passenger.h" #include <vector> using std::vector; #include <fstream> typedef vector<SpaceVehicle*> SV_VEC; void load( SV_VEC& sVec ); enum class MAIN { ADD_SPACE_VEHICLE = 1, DISPLAY, SAVE, EXIT }; enum class DISPLAY { ALL = 1, EXIT }; enum class ADD { FREIGHT = 1, PASSENGER, MODULE, GUEST, EXIT }; void run( SV_VEC& sVec ); void display( ); void process( SV_VEC& sVec, int choice ); void add( SV_VEC& sVec ); void displayAddOptions( ); void processAdd( SV_VEC& sVec, int choice ); void addFreight( SV_VEC& sVec ); void addPassenger( SV_VEC& sVec ); void addModule( SV_VEC& sVec ); void addGuest( SV_VEC& sVec ); void save( const SV_VEC& sVec ); void displayOptions( const SV_VEC& sVec ); void displayMenuOptions( ); void processDisplay( const SV_VEC& sVec, int choice ); void displayAll( const SV_VEC& sVec );

New folder (2)/freight.h

#ifndef FREIGHT_H #define FREIGHT_H #include "spaceVehicle.h" #include "module.h" #include <list> class Freight : public SpaceVehicle { public: Freight( ) = default; private: int maxCap = 0; int currentModules = 0; std::list<Module> cargo; }; #endif

New folder (2)/guest.h

#ifndef GUEST_H #define GUEST_H #include <iostream> #include <fstream> #include <string> class Guest { public: Guest( ) = default; private: std::string name = " unknown"; std::string ticket = "no ticket number set"; }; #endif ~

New folder (2)/makeFile.txt

# make file for CSE1CPP Assignment Part A (Part B and Part C) 2017 CC = g++ LIBS = -g -Wall -std=c++11 spaceWays: spaceVehicle.o module.o freight.o guest.o passenger.o central.o $(CC) $(LIBS) -o spaceWays spaceVehicle.o freight.o passenger.o \ guest.o module.o central.o spaceVehicle.o: spaceVehicle.cpp $(CC) $(LIBS) -c spaceVehicle.cpp central.o: central.cpp $(CC) $(LIBS) -c central.cpp freight.o: freight.cpp $(CC) $(LIBS) -c freight.cpp passenger.o: passenger.cpp $(CC) $(LIBS) -c passenger.cpp module.o: module.cpp $(CC) $(LIBS) -c module.cpp guest.o: guest.cpp $(CC) $(LIBS) -c guest.cpp all: spaceWays clean clean: rm -f *.o

New folder (2)/module.h

#ifndef MODULE_H #define MODULE_H #include <iostream> #include <string> #include <fstream> class Module { public: Module( ) = default; private: std::string modId = "not set"; std::string contents = "empty"; }; #endif

New folder (2)/passanger.h

#ifndef PASSENGER_H #define PASSENGER_H #include "spaceVehicle.h" #include "guest.h" #include <list> class Passenger : public SpaceVehicle { public: Passenger( ) = default; private: int numOfGuests = 0; std::list<Guest> guestList; }; #endif ~

New folder (2)/sc01.dat

Freight HF 002 34 3 C 001 CPP Stuff FG 67 More CPP stuff N 12 Even More CPP stuff Freight A 4 WQ 3 2 A 4 001 WQ Stuff A 4 002 Wouldn't you like to know Passenger L 21 3 First Pass A 01 Second Pass A 02 Third Pass A 03 Freight HF 001 14 0

New folder (2)/spaceVehicle.cpp

#include "spaceVehicle.h" std::ostream& operator << ( std::ostream& os, const SpaceVehicle& sv ) { os << "Type: " << sv.type << std::endl; os << "Id: " << sv.id << std::endl; return os; } std::istream& operator >> ( std::istream& is, SpaceVehicle& sv ) { std::cout << "Enter id >> "; getline( is, sv.id ); return is; } std::ofstream& operator << ( std::ofstream& os, const SpaceVehicle& sv ) { os << sv.type << std::endl; os << sv.id << std::endl; return os; } // already know the type out of the input file (Freight or Passenger) // and set it as it tells us exactly what type of concrete class to make std::ifstream& operator >> ( std::ifstream& is, SpaceVehicle& sv ) { getline( is, sv.id ); return is; }

New folder (2)/spaceVehicle.h

#ifndef SPACE_VEHICLE_H #define SPACE_VEHICLE_H #include <iostream> #include <string> #include <fstream> class SpaceVehicle { public: SpaceVehicle( ) = default; virtual ~SpaceVehicle( ) { } virtual void display( ) const = 0; virtual void fileWrite( std::ofstream& fout ) const = 0; virtual void readIn( ) = 0; virtual void fileReadIn( std::ifstream& fin ) = 0; virtual void setType( ) = 0; const std::string& getType( ) const { return type; } const std::string& getId( ) const { return id; } friend std::ostream& operator << ( std::ostream& os, const SpaceVehicle& sv ); friend std::istream& operator >> ( std::istream& is, SpaceVehicle& sv ); friend std::ofstream& operator << ( std::ofstream& os, const SpaceVehicle& sv ); friend std::ifstream& operator >> ( std::ifstream& is, SpaceVehicle& sv ); protected: std::string type; private: std::string id = "not set yet"; }; #endif