0

hi i am trying to make a function for calculating the commercial boat fee, so if a boat is commercial, the program will add additional fee to the total sum, and if its not it won't add anything to it. i got the function to run, but all i am getting are some really random numbers like 9329030283049283094823 and i don't know how to fix it. Look at the Sailboat::Calcfee and Powerboat::Calcfee function, i think that's where the problem at, or maybe not. buttomline, i DONNO ~_~. this is my first year of doing C++, anyway. Here is my code:

```
#include <iostream>
#include <string>
#include <cctype>
#include <typeinfo>
using namespace std;
class Boatyard
{
protected:
double length;
double beam;
double draft;
string name;
int material;
int manufacture;
bool commercial;
const static char CH=20;
static double L_MAX;
static double L_MIN;
static double B_MAX;
static double B_MIN;
static double D_MAX;
static double D_MIN;
static int M_MAX;
static int M_MIN;
static int MA_MAX;
static int MA_MIN;
public:
string Key();
bool Commercial();
void Commercial(bool _z);
double Length();
void Length(double _z);
double Beam();
void Beam(double _z);
double Draft();
void Draft(double _z);
string Name();
void Name(string _z);
int Material();
void Material(int _z);
int Manufacture();
void Manufacture(int _z);
virtual void Calcfee(double _z)=0;
virtual void show()=0;
Boatyard();
Boatyard(double _len, double _bea, double _dra, string _bnam, int _mat, int _manuf, bool _com);
Boatyard(const Boatyard &_b);
double _validateLBD(double _z, const double MAX, const double MIN);
int Boatyard::_validateMAMAN(int _z, const int MAX, const int MIN);
}; // end declaration
class Sailboat : public Boatyard
{
protected:
int rig;
int hull;
double sailfee;
static int MAX_RIG;
static int MIN_RIG;
static int MAX_HULL;
static int MIN_HULL;
public:
int Rig();
void Rig(int _z);
int Hull();
void Hull(int _z);
double Calcfee();
void Calcfee(double _z);
void show();
Sailboat();
Sailboat(double _len, double _bea, double _dra, string _bnam, int _mat, int _manuf, bool _com, int _ri, int _hul);
Sailboat(const Sailboat & _s);
int _validation(int _z, const int MAX, const int MIN);
};//end of sailboat class
class Powerboat : public Boatyard
{
protected:
int hp;
int fuel;
double powerfee;
static int MAX_HP;
static int MIN_HP;
static int MAX_FUEL;
static int MIN_FUEL;
public:
int Hp();
void Hp(int _z);
int Fuel();
void Fuel(int _z);
double Calcfee();
void Calcfee(double _v);
void show();
Powerboat();
Powerboat(double _len, double _bea, double _dra, string _bnam, int _mat, int _manuf, bool _com, int _hp, int _fue);
Powerboat(const Powerboat & _p);
int _validationz(int _z, const int MAX, const int MIN);
};//end of powerboat class
double Boatyard::Length(){return length;}
void Boatyard::Length(double _z)
{
length = _validateLBD(length, L_MAX, L_MIN);
}
double Boatyard::Beam(){return beam;}
void Boatyard::Beam(double _z)
{
beam = _validateLBD(beam, B_MAX, B_MIN);
}
double Boatyard::Draft(){return draft;}
void Boatyard::Draft(double _z)
{
draft = _validateLBD(draft, D_MAX, D_MIN);
}
string Boatyard::Key(){return name;}
string Boatyard::Name(){return name;}
void Boatyard::Name(string _z)
{
if(_z.length()<=CH)
{
name = _z;
}
else
name= _z.substr(0,CH);
}
bool Boatyard::Commercial(){return commercial;}
void Boatyard::Commercial(bool _z)
{
commercial = _z;
}
int Boatyard::Material(){return material;}
void Boatyard::Material(int _z)
{
material = _validateMAMAN(material, M_MAX, M_MIN);
}
int Boatyard::Manufacture(){return manufacture;}
void Boatyard::Manufacture(int _z)
{
manufacture = _validateMAMAN(manufacture, MA_MAX, MA_MIN);
}
Boatyard::Boatyard() : length(),beam(),draft(),name(),material(),manufacture(),commercial()
{
}
Boatyard::Boatyard(double _len, double _bea, double _dra, string _bnam, int _mat, int _manuf, bool _com):length(_len), beam(_bea), draft(_dra), name(_bnam), material(_mat), manufacture(_manuf), commercial(_com)
{
Length(length);
Beam(beam);
Draft(draft);
Name(name);
Material(material);
Manufacture(manufacture);
}
Boatyard::Boatyard(const Boatyard &_b){};
void Boatyard::show()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << "Length:" << length << " Meter " << "Beam:" << beam << " Meter " <<"Draft: " << draft <<" Meter " << endl << "Person's Name: "<< name << " Material: " << material << " Manufacture: " << manufacture << endl;
}
//end of implementation for Boatyard
int Sailboat::Rig(){return rig;}
void Sailboat::Rig(int _z)
{
rig = _validation(rig,MAX_RIG,MIN_RIG);
}
int Sailboat::Hull(){return hull;}
void Sailboat::Hull(int _z)
{
hull = _validation(hull, MAX_HULL, MIN_HULL);
}
double Sailboat::Calcfee(){return sailfee;}
void Sailboat::Calcfee(double _z)
{
double LOA = length;
if (commercial = false)
{
_z = LOA*50;
}
if (commercial = true)
{
_z = LOA*50+7.5;
}
}
Sailboat::Sailboat() :Boatyard(), rig (), hull (){};
Sailboat::Sailboat(double _len, double _bea, double _dra, string _bnam, int _mat, int _manuf, bool _com, int _ri, int _hul ) : Boatyard( _len, _bea, _dra, _bnam, _mat, _manuf, _com),rig(_ri),hull(_hul){};
Sailboat::Sailboat(const Sailboat &_s):Boatyard(_s),rig( _s.rig),hull( _s.hull){};
void Sailboat::show()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << "Sailboat" << endl << "Length:" << this->length << " Meter " << "Beam:" << this->beam << " Meter " <<"Draft: " << this->draft <<" Meter " << endl << "Person's Name: "<< this->name << " Material: " << this->material << " Manufacture: " << this->manufacture << "Sailboat Fee: " << this->sailfee << " $ " << " Rig:" << this-> rig << " Hull: " << this->hull << endl;
}
int Powerboat::Hp(){return hp;}
void Powerboat::Hp(int _z)
{
hp = _validationz(hp,MAX_HP,MIN_HP);
}
int Powerboat::Fuel(){return fuel;}
void Powerboat::Fuel(int _z)
{
fuel = _validationz(fuel,MAX_FUEL,MIN_FUEL);
}
double Powerboat::Calcfee(){return powerfee;}
void Powerboat::Calcfee(double _z)
{
if(commercial = false)
{
if(hp < 150)
{
_z = ((length*50)+100)+7.5;
}
if((hp >150)&&(hp < 301))
{
_z = ((length*50)+150)+7.5;
}
if(hp > 300)
{
_z = ((length*50)+200)+7.5;
}
}
if(commercial = true)
{
if(hp < 150)
{
_z = ((length*50)+100);
}
if((hp >150)&&(hp < 301))
{
_z = ((length*50)+150);
}
if(hp > 300)
{
_z = ((length*50)+200);
}
}
}
Powerboat::Powerboat() :Boatyard(), hp(), fuel(){};
Powerboat::Powerboat(double _len, double _bea, double _dra, string _bnam, int _mat, int _manuf, bool _com, int _hp, int _fue) :Boatyard( _len, _bea, _dra, _bnam, _mat, _manuf, _com),hp( _hp),fuel( _fue){};
Powerboat::Powerboat(const Powerboat &_p):Boatyard(_p),hp(_p.hp),fuel(_p.fuel){};
void Powerboat::show()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << "Powerboat" << endl << "Length:" << this->length << " Meter " << "Beam:" << this->beam << " Meter " <<"Draft: " << this->draft <<" Meter " << endl << "Person's Name: "<< this->name << " Material: " << this->material << " Manufacture: " << this->manufacture << "Powerboat Fee: " << this->powerfee << " $" << "HorsePower" << this->hp << "Fuel Type: " << this->fuel << endl;
}
double Boatyard::_validateLBD(double _z, const double MAX, const double MIN)
{
if(_z > MAX)
{
return -1;
}
if(_z < MIN)
{
return -1;
}
return _z;
}
int Boatyard::_validateMAMAN(int _z, const int MAX, const int MIN)
{
if(_z > MAX)
{
return 0;
}
if(_z < MIN)
{
return 0;
}
return _z;
}
int Powerboat::_validationz(int _z, const int MAX, const int MIN)
{
if(_z < MIN)
{
return -1;
}
if(_z > MAX)
{
return -1;
}
return _z;
}
int Sailboat::_validation(int _z, const int MAX, const int MIN)
{
if(_z > MAX)
{
return 0;
}
if(_z < MIN)
{
return 0;
}
return _z;
}
int Powerboat::MAX_HP = 400;
int Powerboat::MIN_HP = 0;
int Powerboat::MAX_FUEL = 3;
int Powerboat::MIN_FUEL = 1;
int Sailboat::MAX_RIG = 2;
int Sailboat::MIN_RIG = 1;
int Sailboat::MAX_HULL = 2;
int Sailboat::MIN_HULL = 1;
double Boatyard::L_MAX = 10;
double Boatyard::L_MIN = 3;
double Boatyard::B_MAX = 3;
double Boatyard::B_MIN = 1;
double Boatyard::D_MAX = 2;
double Boatyard::D_MIN = .25;
int Boatyard::M_MAX = 4;
int Boatyard::M_MIN = 1;
int Boatyard::MA_MAX = 3;
int Boatyard::MA_MIN = 1;
void Printthem(Boatyard * _obj);
void main()
{
Sailboat a(3,1,2,"BIGCANNON",2,1,true,1,2);
a.show();
}
void printthem(Boatyard * _obj)
{
Boatyard * _b = dynamic_cast<Boatyard *> (_obj);
Sailboat * _s = dynamic_cast<Sailboat *> (_obj);
Powerboat * _p = dynamic_cast<Powerboat *> (_obj);
}
```