|
/* ---------------------------------------------------------
Super Star Trek
C++ Port Copyright 2008, James M. Curran <jamescurran@mvps.org>
based upon the C Port, Copyright 1996, Chris Nystrom
based upon the PC Basic port, Copyright 1978, Workman Publishing
based upon the HP Basic original, PD circa 1971, Mike Mayfield
C++ code licensed using the Code Project Open License v1.02
http://www.codeproject.com/info/cpol10.aspx
-------------------------------------------------------------- */
// Shields.cpp: implementation of the Shields class.
//
//////////////////////////////////////////////////////////////////////
#include "Shields.h"
#include "Ship.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Shields::Shields(Ship& s): ShipSystem(s)
{
nLevel = 0;
}
Shields::~Shields()
{
}
bool Shields::activate()
{
cout << "Energy available = " << ship.Energy() + GetLevel() << endl << endl;
cout << "Input number of units to sheilds: ";
int nNewShields;
cin >> nNewShields;
cout << endl;
if ( (nNewShields < 0) || nLevel == nNewShields)
{
cout << "<Sheilds Unchanged>" << endl << endl;
}
else
{
if (nNewShields >= ship.Energy() + nLevel)
{
cout << "Sheild Control Reports:" << endl;
cout << " 'This is not the Federation Treasury.'" << endl;
cout << "<Sheilds Unchanged>" << endl << endl;
}
else
{
ship.AddEnergy(nLevel); // put back what we were using
ship.UseEnergy(nNewShields); // remove what we are using.
SetLevel(nNewShields);
cout << "Deflector Control Room report:" << endl;
cout << " 'Shields now at " << nLevel << " units per your command.'" << endl << endl;
}
}
return(true);
}
int Shields::BorrowFromReserves(int eng)
{
int energy = std::min(this->nLevel, eng);
nLevel -= energy;
return energy;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
20+ years as a developer : Assembly, C, C++ and C# (in that order) with sidelines in ASP/VBScript, ASP.Net, JavaScript, Perl, QuickBasic, VisualBasic, plus a few others which I'm not going to mention because if I did someone might ask me to use them again (shudder)
Microsoft MVP in VC++ (1994-2004)
I also run www.NJTheater.com as a hobby.
Full resume & stuff at NovelTheory.com
Underused blog at HonestIllusion.com