#ifndef STONEWT_H
#define STONEWT_H
class Stone
{
private:
enum {div = 14};
int stone;
double point;
double pounds;
public :
Stone();
Stone(int s,double pt);
Stone(double pds);
~Stone();
Stone operator * (double pds);
void show();
};
#endif
=======================================================
#include "stonewt.h"
#include <iostream>
using namespace std;
Stone::Stone()
{}
Stone::Stone(int s,double pt)
{
stone = s;
point = pt;
pounds = s*div+pt;
}
Stone::Stone(double pds){
stone = (int)pds / div;
point = (int)pds % div + pds - (int)pds;
pounds = pds;
}
Stone::~Stone() {}
Stone Stone::operator * (double pds)
{
Stone s;
/*int sstone = (int)pds / div;
double spoint = (int)pds % div + pds - (int)pds;
//double spounds = pds;*/
s.point = int (point * pds) % div + pds - (int)pds;
s.stone = stone * (int)pds + int(point * pds) / div;
return s;
}
void Stone::show()
{
cout << "The result is: " << stone << " stone " << point << " pounds" << endl;
}
============================================================
#include "stonewt.h"
int main()
{
Stone st(5,3),st1;
st1 = st * 6.5;
st1.show();
return 0;
}