|
/* ---------------------------------------------------------
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
-------------------------------------------------------------- */
// ShipSystem.cpp: implementation of the ShipSystem class.
//
//////////////////////////////////////////////////////////////////////
#include "ShipSystem.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ShipSystem::ShipSystem(Ship& s) : nDamageLevel(0), ship(s)
{
}
void ShipSystem::RepairDamage(double d)
{
this->nDamageLevel += d;
if (this->nDamageLevel > -0.1 && this->nDamageLevel < 0.0)
{
this->nDamageLevel = -0.1;
}
}
void ShipSystem::ReportDamage(ShipSystem& system)
{
cout.width(20);
cout << std::left << system.name() << '\t' << system.nDamageLevel << endl;
}
double ShipSystem::TimeToFix(ShipSystem& system)
{
return (system.isDamaged()) ? 0.1 : 0.0;
}
void ShipSystem::FixDamage(ShipSystem& system)
{
if (system.isDamaged())
system.nDamageLevel = 0.0;
}
bool ShipSystem::DoCommand()
{
bool bRet = true;
if (isDamaged())
cout << endl << "*** " << name() << " is out ***" << endl;
else
bRet = activate();
return(bRet);
}
double ShipSystem::AcceptCourse(string officer)
{
double course;
cout << "Course (1-9): ";
cin >> course;
cout << endl;
if (course == 9.0)
course = 1.0;
if (course <1.0 || course > 9.0)
{
cout << officer << "reports:" << endl;
cout << " Incorrect course data, sir!" << endl << endl;
course = 0.0;
}
return course;
}
|
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