Investor second opinion

I am currently working on a lab for class as follows;

A. Use Tiles instead of squares.
B. The Tortoise and the Hare are Real Estate Investors

Implement a class Tile with the following properties
Admission Cost (randomize cost between $3 and $10)
Tile Cost (randomize cost between 6 and $20)
Cost to build one Green House (5 x Tile Cost)
Green House Count
Investor *owner
void place(Investor *) – Function is called to place Investor on Tile


Implement a class Investor with the following properties:
Name of Investor
Cash Savings Balance (initialize to $15000)
Total value of Assets (initialize to $0)
void savingsDeposit(double amount ) – Deposits money into cash savings balance.
void assetDeposit(double amount) – add to the value of assets.
double withdraw(double amount)

I am a little lost as to how I should code my .h files specially my Investor.h here is the code for that file;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <string>

const int RACE_END = 70;

class Investor
{
public:
	Investor();
	void savingsDeposit(double amount);// deposits money into cash savings balance
	void assetDeposit(double amount);// add to the value of assets
	double withdraw(double amount);	// withdraws money from accounts
	double cashSavingBalance(double balance);// initialize to $0
	double totalValueAssets(double value);	// initialize to $15000
	string investorName(string name);	// name of investor

private:
	string inName;	// investor name
	double aDeposit;// asset deposit
	double sDeposit;// savings deposit
	double aValue;	// asset value
	double sBalance;// savings balance
	double moneyOut;// withdraw
};


I would like to get a second opinion see if i am in the right path, or if you guys have any suggestions thanks in advance.
Last edited on
Your code is very neat and consistent, and well done. The one suggestion I have is adding some form of controller or config class and putting the constant value there (static const int, and then initialise it in the source file). Additionally add header guards or "#pragma once" at the top of the header to avoid the source file being parsed more than once.

Are you able to manage the dependant (.cpp) source definitions for the header of this class?
I have put the cpp if you could check them out see if it is correct;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
#include "Investor.h"
using namespace std;

Investor::Investor()
{
	inName = " ";// investor name
	aValue = 0.0;// asset value
	sBalance = 15000.0;// savings balance
	moneyOut = 0.0;// withdraw
	aDeposit = 0.0;	// asset deposit
	sDeposit = 0.0;	// savings deposit
	
}

// deposits money into cash savings balance
void Investor::savingsDeposit(double amount)
{
	amount = sDeposit + amount;
}

// add to the value of assets
void Investor::assetDeposit(double amount)
{
	amount = aDeposit + aValue;
}

// withdraws money from accounts
double Investor::withdraw(double amount)
{
	amount = moneyOut + amount;
}

// initialize to $15000
double Investor::cashSavingBalance(double balance)
{
	balance = sBalance + balance;
}

// initialize to $0
double Investor::totalValueAssets(double balance)
{	
	balance = aValue + balance;
}

string Investor::investorName(string name)
{
	name = inName;
}


for the investorName should I add a void setInvestorName and use the current string investorName to set the name? considering that i am dealing with the Tortoise and the Hare as investors?
Last edited on
Topic archived. No new replies allowed.