rendered paste body#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstring>
#include "transaction.h"
#include "holding.h"
using namespace std;
int main()
{
}
/////////////
#include <cstring>
using namespace std;
class holding
{
private:
string company;
int shares;
double price;
string symbol;
public:
//Holding constructor
holding(string in_company, int in_shares, double in_price, string in_symbol);
//Getters
string getCompany() const {return company;}
int getShares() const {return shares;}
double getPrice() const {return price;}
string getSymbol() const {return symbol;}
//Setters
void setCompany(string in_company);
void setSymbol(string in_symbol);
void setShares(int in_shares);
bool setPrice(double in_price);
//Other
void updatePrice();
void printHolding();
};
/////////////////////////
#include "holding.h"
#include <ctime>
#include <iostream>
#include <cstdlib>
#include <cstring>
using std::string;
class holding
{
public:
//Constructor
holding::holding(string in_company, int in_shares, double in_price, string in_symbol)
{
company = in_company;
shares = in_shares;
price = in_price;
symbol = in_symbol;
}
//Setters
void setCompany(string in_company)
{
company = in_company;
}
void setSymbol(string in_symbol)
{
symbol = in_symbol;
}
void setShares(int in_shares)
{
shares = in_shares;
}
bool setPrice(double in_price)
{
if(in_price > 0)
{
price = in_price;
return true;
}
return false;
}
//Other functions
void updatePrice()
{
int random_1 = (rand()%2);
int random_2 = (rand()%5)+1;
if(random_1 == 0)
price -= random_2;
elseif(random_1 == 1)
price += random_2;
}
void printHolding()
{
cout << "You own " << shares << " shares of " << company << " [" << symbol << "] stocks at $" << price << "per share." << endl;
}
};
////////////////////////////
#include <cstring>
using namespace std;
class transaction
{
private:
string company;
char buyorsell;
int shares;
double price;
public:
//Tranaction constructor
transaction(string in_company, char in_buyorsell, int in_shares, double in_price);
//Getters
string getCompany() const {return company;}
char getBuySell() const {return buyorsell;}
int getShares() const {return shares;}
double getPrice() { return price;}
//Setters
void setCompany(string in_company);
bool setBuyorSell(char in_buyorsell);
bool setShares(int in_shares);
bool setPrice(double in_price);
//Other
void printTransaction();
};
///////////////////////////////////////////
#include <cstring>
#include "transaction.h"
using namespace std;
class transaction
{
public:
//Tranaction constructors
transaction::transaction(string in_company, char in_buyorsell, int in_shares, double in_price)
{
company = in_company;
if(in_buyorsell == 'b' || in_buyorsell == 's')
buyorsell = in_buyorsell;
if(in_shares > 0)
shares = in_shares;
if(in_price > 0)
price = in_price;
}
//Setters
void transaction::setCompany(string in_company)
{
company = in_company;
}
bool transaction::setBuySell(char in_buyorsell)
{
if(in_buyorsell == 'b' || in_buyorsell == 's')
{
buyorsell = in_buyorsell;
return true;
}
return false;
}
bool transaction::set_Shares(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;
}
void transaction::print_Transaction()
{
if(buyorsell == 'b')
cout << "You bought ";
elseif(buyorsell == 's')
cout << "You sold ";
cout << shares << " shares of " << company << " stock for $" << price << endl;
}
};