I thought I had figured out how to create classes, until I had to use numbers in them. The example I was given did not use them, and the problem for my assignment has almost nothing to do with the example. My problem is that I'm not sure how to go forward with implementing the use of a static random number generator, or the addition of an array.
Here's the assignment:
Define the class bankAccount to implement the basic properties of a
bank account. An object of this class should store the following data:
Account holder’s name (string), account number (int), account
type (string, checking/saving), balance (double), and interest rate
(double). (Store interest rate as a decimal number.) Add appropriate
member functions to manipulate an object. Use a static member
in the class to automatically assign account numbers. Also declare
an array of 10 components of type bankAccount to process up to
10 customers and write a program to illustrate how to use your class.
My cpp file:
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#include <iostream>
#include <string>
#include "bankAccount.h"
using namespace std;
void bankAccount::print() const
{
cout << accNum << " " << name << " " << type << " " << bal << " " << rate << endl;
}
void bankAccount::setName(string name)
{
fullName = name;
}
void bankAccount::setType(string type)
{
accType = type;
}
void bankAccount::setAccNum(int num)
{
accNum = num;
}
void bankAccount::setBal(double bal)
{
accBal = bal;
}
void bankAccount::setRate(double rate)
{
interestRate = rate;
}
bool bankAccount::isFullName(string name) const
{
return (fullName == name);
}
bool bankAccount::isAccType(string type) const
{
return (accType == type);
}
bool bankAccount::isAccNum(int num) const
{
return (accNum == num);
}
bool bankAccount::isAccBal(double bal) const
{
return (accBal == bal);
}
bool bankAccount::isInterestRate(double rate) const
{
return (interestRate == rate);
}
string bankAccount::getFullName() const
{
return fullName;
}
string bankAccount::getAccType() const
{
return accType;
}
int bankAccount::getAccNum() const
{
return accNum;
}
double bankAccount::getAccBal() const
{
return accBal;
}
double bankAccount::getInterestRate() const
{
return interestRate;
}
bankAccount::bankAccount(string name, string type, int num, double bal, double rate)
{
fullName = name;
accType = type;
accNum = num;
accBal = bal;
interestRate = rate;
}
|