Hello, I was wondering if I could get advice on a project me and my friend are working on. Basically it's on a Trade Stock based system that is user interactive, and right now we're trying to make it possible for the user to be able to insert the Amount of shares they want to buy of one stock. We're thinking of using an ARRAY OF CLASS OBJECTS method to solve this issue, but we keep getting stuck on it. Can someone please explain if that might be helpful or if we need to use something else? If you'd like to see the main file, I'll post it in a comment, just because it's too long for it to be here. Any advice would really be helpful, please respond soon, Thank You.
STOCK.H
#ifndef STOCK_H
#define STOCK_H
#include<iostream>
#include<string>
using namespace std;
class Stock
{
public:
Stock(const string, const string, double, int = 500); // number of shares defaults to 500 if nothing is entered in
//Stock s[int];
void Stock::setTradingTicker(const string trade)
{
if((trade.length() > 1) && (trade.length() < 4))
TradingTicker = trade;
else
throw invalid_argument ( "Trading ticker name must be more than 1 character and less than 4 characters.");
}
void Stock::setNumOfAvailableShares(int amount)
{
if(amount > 0)
NumberOfShares = amount;
else
throw invalid_argument ("Invalid number of shares entered. Number of shares set to 500.");
}
int Stock::getNumOfAvailableShares()
{
return NumberOfShares;
}