1-3 Please do all three parts. Short code tasks in c++ and follow the given inst
ID: 3862051 • Letter: 1
Question
1-3 Please do all three parts. Short code tasks in c++ and follow the given instructions.thanks! Required Classes and Methods NOT functions. To receive full credit, programmers must apply coding conventions for code block indentation, comments describing methods/classes, white space between code blocks. and variable/method class naming conventions. Implement Inheritance, Getters, Setters, and other OOP tools as needed. Create 2 int arrays. Array1[1000] and Array 20100000] Create methods to fill the array with random integersExplanation / Answer
1)
class person
{
//class variables
private:
int health;
int money;
//class methods
public:
person();//cpnstructor
~person();//destructer
//setters
void set_health(int h);
void set_money(int m);
//getters
int get_health();
int get_money();
};
person::person()
{
health = 100;
money = 35;
}
person::~person()
{
}
//Setters implementation
void person::set_health(int h)
{
health = h;
}
void person::set_money(int m)
{
money = m;
}
//Getters implementation
int person::get_health()
{
return health;
}
int person::get_money()
{
return money;
}
2)
creating arrays is simple
int array1[1000];
int array2[1000];
3)
void random_num(int* array[]) //address of the array should be passed
{
srand(null); //to initialize the time for every call
for(int i=0;i<sizeof(array);i++)
{
array[i]=rand(); //random number assigning
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.