rendered paste body////////Transaction.h
#ifndef _HOLDING_H_
#define _HOLDING_H_
#include <string>
using namespace std;
class transaction
{
private:
string company;
char buyorsell;
int shares;
double price;
public:
//Getters
string getCompany(){return company;}
char getBuyorsell(){return buyorsell;}
int getShares(){return shares;}
double getPrice(){return price;}
//Setters
void setCompany(int in_company){company = in_company;}
bool setBuyorsell();
bool setShares();
bool setPrice();
//Other functions
void printTransaction();
void getTransaction(string in_company, char in_buyorsell, int in_shares, double in_price);
};
#endif
///////////
///////////Transaction.cxx
#include "transaction.h"
#include <string>
using namespace std;
class transaction
{
public:
//Setters
bool transaction::setBuyorsell(char in_buyorsell)
{
if(in_buyorsell == 'b')
{
buyorsell = 'b';
return true;
}
elseif(buyorsell == 's')
{
buyorsell = 's';
return true;
}
return false;
}
bool transaction::setShares(int in_shares)
{
if(in_shares > 0 )
{
shares = in_shares;
return true;
}
return false;
}
bool transaction::setPrice(double in_price)
{
if(in_price > 0)
{
price = in_price;
return true;
}
return false;
}
//Other functions
void printTransaction()
{
if(buyorsell == 'b')
cout << "You bought ";
elseif(buyorsell == 's')
cout << "You sold ";
cout << shares << " shares of " << company << " stock for $" << price << endl;
}
void getTransaction(string in_company, char in_buyorsell, int in_shares, double in_price)
{
setCompany(in_company);
setBuyorsell(in_buyorsell);
setShares(in_shares);
setPrice(in_price);
}
};