Fleet Simulation Source Code

 < Day Day Up > 



ciws.h

ciws.h

start example
#ifndef MY_CIWS_H #define MY_CIWS_H #include "weapon.h" class Ciws : public Weapon{     public:         Ciws(char *theModel, int theBullets);         virtual ~Ciws();         virtual void Train_Weapon();         virtual void Fire_Weapon();     private:         char *itsModel;         int itsBullets;         static int count; }; #endif
end example

five_inch.h

five_inch.h

start example
#ifndef MY_FIVE_INCH_H #define MY_FIVE_INCH_H #include "weapon.h" class Five_Inch : public Weapon{     public:         Five_Inch(char *theModel, int theBullets);         virtual ~Five_Inch();         virtual void Train_Weapon();         virtual void Fire_Weapon();     private:         char *itsModel;         int itsBullets;         static int count; }; #endif
end example

torpedo.h

torpedo.h

start example
#ifndef MY_TORPEDO_H #define MY_TORPEDO_H #include "weapon.h" class Torpedo : public Weapon{     public:         Torpedo(char *theModel, int theBullets);         virtual ~Torpedo();         virtual void Train_Weapon();         virtual void Fire_Weapon();     private:         char *itsModel;         int itsBullets;         static int count; }; #endif
end example

gasturbine.h

gasturbine_plant.h

start example
#ifndef MY_GAS_TURBINE_PLANT #define MY_GAS_TURBINE_PLANT #include "plant.h" class GasTurbine_Plant : public Plant{     public:         GasTurbine_Plant(char *theModel);         virtual ~GasTurbine_Plant();         virtual void LightOff_Plant();        virtual void ShutDown_Plant();        virtual bool Get_Plant_Status();         private:         char *itsModel;         static int count;         bool status;  }; #endif
end example

nuke_plant.h

nuke_plant.h

start example
#ifndef MY_NUKE_PLANT_H #define MY_NUKE_PLANT_H #include "plant.h" class Nuke_Plant : public Plant{     public:         Nuke_Plant(char *theModel);         virtual ~Nuke_Plant();         virtual void LightOff_Plant();         virtual void ShutDown_Plant();         virtual bool Get_Plant_Status();      private:         char *itsModel;         static int count;         bool status; }; #endif
end example

steam_plant.h

steam_plant.h

start example
#ifndef MY_STEAM_PLANT_H #define MY_STEAM_PLANT_H #include "plant.h" class Steam_Plant : public Plant{     public:       Steam_Plant(int thePsi);       virtual ~Steam_Plant();       virtual void LightOff_Plant();       virtual void ShutDown_Plant();        virtual bool Get_Plant_Status();      private:       int itsPsi;       static int count;       bool status; }; #endif
end example

submarine.h

submarine.h

start example
#ifndef MY_SUBMARINE_H #define MY_SUBMARINE_H #include "vessel.h" class Submarine : public Vessel{     public:       Submarine(Plant &thePlant, Weapon &theWeapon, char *theName);       virtual ~Submarine();       virtual void LightOff_Plant();       virtual void ShutDown_Plant();       virtual void Train_Weapon();       virtual void Fire_Weapon();       virtual bool Get_Plant_Status();     private:       char *itsName;       static int count;  }; #endif
end example

surface_ship.h

surface_ship.h

start example
#ifndef MY_Surface_Ship_H #define MY_Surface_Ship_H #include "vessel.h" class Surface_Ship : public Vessel{     public:       Surface_Ship(Plant &thePlant, Weapon &theWeapon, char *theName);       virtual ~Surface_Ship();       virtual void LightOff_Plant();       virtual void ShutDown_Plant();       virtual void Train_Weapon();       virtual void Fire_Weapon();       virtual bool Get_Plant_Status();     private:       char *itsName;       static int count;  }; #endif
end example

ciws.cpp

ciws.cpp

start example
#include "Ciws.h" #include <iostream.h> int Ciws::count = 0; Ciws::Ciws(char *theModel, int theBullets) : Weapon(), itsBullets(theBullets),           itsModel(theModel){ Ciws::count++;} Ciws::~Ciws(){ Ciws::count--;} void Ciws::Train_Weapon(){      cout<<"Ciws is locked on target!"<<endl; } void Ciws::Fire_Weapon(){      if(itsBullets){      cout<<"Sabots Away!"<<endl;      itsBullets--;      }      else        cout<<"Ciws Out Of Ammo!"<<endl; }
end example

five_inch.cpp

five_inch.cpp

start example
#include "five_inch.h" #include <iostream.h> int Five_Inch::count = 0; Five_Inch::Five_Inch(char *theModel, int theBullets) : Weapon(), itsBullets(theBullets),           itsModel(theModel){ Five_Inch::count++;} Five_Inch::~Five_Inch(){ Five_Inch::count--;} void Five_Inch::Train_Weapon(){      cout<<"Five Inch Gun is locked on target!"<<endl; } void Five_Inch::Fire_Weapon(){      if(itsBullets)      {      cout<<"Blam!"<<endl;      itsBullets--;      }       else          cout<<"Five Inch Gun Out Of Ammo!"<<endl; }
end example

gasturbine_plant.cpp

gasturbine_plant.cpp

start example
#include <iostream.h> #include "gasturbine_plant.h" int GasTurbine_Plant::count = 0; GasTurbine_Plant::GasTurbine_Plant(char *theModel) : itsModel(theModel), status(false){      GasTurbine_Plant::count++; } GasTurbine_Plant::~GasTurbine_Plant(){      GasTurbine_Plant::count--; } void GasTurbine_Plant:: LightOff_Plant(){      cout<<"Gas Turbine Plant Lit Off!"<<endl;      cout<<"All Indications Normal!"<<endl;      status = true; } void GasTurbine_Plant::ShutDown_Plant(){      cout<<"GasTurbine Plant Shut Down!"<<endl;      status = false; } bool GasTurbine_Plant::Get_Plant_Status(){      if(status)        cout<<"The "<<itsModel<<" is running fine!"<<endl;        else          cout<<"Gas Turbine Plant Secured!"<<endl;        return status; }
end example

nuke_plant.cpp

nuke_plant.cpp

start example
#include <iostream.h> #include "nuke_plant.h" int Nuke_Plant::count = 0; Nuke_Plant::Nuke_Plant(char *theModel) : itsModel(theModel), status(false){      Nuke_Plant::count++; } Nuke_Plant::~Nuke_Plant(){      Nuke_Plant::count--; } void Nuke_Plant:: LightOff_Plant(){      cout<<"Reactor Critical!"<<endl;      status = true; } void Nuke_Plant::ShutDown_Plant(){      cout<<"Nuke Plant Shut Down!"<<endl;      status = false; } bool Nuke_Plant::Get_Plant_Status(){      if(status)        cout<<"The "<<itsModel<<" is running fine!"<<endl;        else          cout<<"Nuke plant secured!"<<endl;       return status; }
end example

steam_plant.cpp

steam_plant.cpp

start example
#include <iostream.h> #include "steam_plant.h" int Steam_Plant::count = 0; Steam_Plant::Steam_Plant(int thePsi) :itsPsi(thePsi), status(false){      Steam_Plant::count++; } Steam_Plant::~Steam_Plant(){      Steam_Plant::count--; } void Steam_Plant:: LightOff_Plant(){      cout<<"Steam Plant Lit Off!"<<endl;      cout<<"Stack Clear!"<<endl;      status = true; }       void Steam_Plant::ShutDown_Plant(){      cout<<"Steam Plant Shut Down!"<<endl;      status = false; } bool Steam_Plant::Get_Plant_Status(){      if(status)        cout<<"Plant's running fine! There's "<<itsPsi<<" psi at the main stop valves!"<<endl;        else          cout<<"Steam plant secured!"<<endl;       return status; }
end example

submarine.cpp

submarine.cpp

start example
#include "submarine.h" #include <iostream.h> #include "plant.h" #include "weapon.h" int Submarine::count = 0; Submarine::Submarine(Plant &thePlant, Weapon &theWeapon, char *theName)                      : Vessel(thePlant, theWeapon), itsName(theName){     if((++Submarine::count) == 1)     cout<<"Constructor: There is "<<Submarine::count<<" submarine."<<endl;     else          cout<<"Constructor: There are "<<Submarine::count<<" submarines."<<endl; } Submarine::~Submarine(){     if((--Submarine::count) == 1)      cout<<"Destructor: There is "<<Submarine::count<<" submarine."<<endl;      else          cout<<"Destructor: There are "<<Submarine::count<<" submarines."<<endl; } void Submarine::LightOff_Plant(){      GetPlant().LightOff_Plant(); } void Submarine::ShutDown_Plant(){      GetPlant().ShutDown_Plant(); } void Submarine::Train_Weapon(){      GetWeapon().Train_Weapon(); } void Submarine::Fire_Weapon(){      GetWeapon().Fire_Weapon(); } bool Submarine::Get_Plant_Status(){      return GetPlant().Get_Plant_Status(); }
end example

surface_ship.cpp

surface_ship.cpp

start example
#include "Surface_Ship.h" #include <iostream.h> #include "plant.h" #include "weapon.h" int Surface_Ship::count = 0; Surface_Ship::Surface_Ship(Plant &thePlant, Weapon &theWeapon, char *theName)                      : Vessel(thePlant, theWeapon), itsName(theName){     if((++Surface_Ship::count) == 1)     cout<<"Constructor: There is "<<Surface_Ship::count<<" surface ship."<<endl;     else          cout<<"Constructor: There are "<<Surface_Ship::count<<" surface ships."<<endl; } Surface_Ship::~Surface_Ship(){     if((--Surface_Ship::count) == 1)     cout<<"Destructor: There is "<<Surface_Ship::count<<" surface ship."<<endl;     else          cout<<"Destructor: There are "<<Surface_Ship::count<<" surface ships."<<endl; } void Surface_Ship::LightOff_Plant(){     GetPlant().LightOff_Plant(); } void Surface_Ship::ShutDown_Plant(){     GetPlant().ShutDown_Plant(); } void Surface_Ship::Train_Weapon(){     GetWeapon().Train_Weapon(); } void Surface_Ship::Fire_Weapon(){     GetWeapon().Fire_Weapon(); } bool Surface_Ship::Get_Plant_Status(){     return GetPlant().Get_Plant_Status(); }
end example

torpedo.cpp

torpedo.cpp

start example
#include "torpedo.h" #include <iostream.h> int Torpedo::count = 0; Torpedo::Torpedo(char *theModel, int theBullets) : Weapon(), itsBullets(theBullets),           itsModel(theModel){Torpedo::count++;} Torpedo::~Torpedo(){Torpedo::count--;} void Torpedo::Train_Weapon(){      cout<<"Torpedo is locked on target!"<<endl; } void Torpedo::Fire_Weapon(){      if(itsBullets)      {      cout<<"Fish In The Water!"<<endl;      itsBullets--;      }      else         cout<<"Fresh Out Of Torpedos Captain!"<<endl; }
end example

vessel.cpp

vessel.cpp

start example
#include "vessel.h" #include <iostream.h> int Vessel::count = 0; Vessel::Vessel(Plant &thePlant, Weapon &theWeapon) : itsPlant(thePlant),               itsWeapon(theWeapon) {      if((++Vessel::count) == 1)      cout<<"Constructor: There is "<<Vessel::count<<" vessel."<<endl;      else           cout<<"Constructor: There are "<<Vessel::count<<" vessels."<<endl; } Vessel::~Vessel(){      if((--Vessel::count) == 1)      cout<<"Destructor: There is "<<Vessel::count<<" vessel."<<endl;      else           cout<<"Destructor: There are "<<Vessel::count<<" vessels."<<endl; }
end example



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net