Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new multifile project using the Resistor class,include a new main() tes

ID: 3647702 • Letter: C

Question

Create a new multifile project using the Resistor class,include a new main() test function.

Add a static data member of the class Resistor to keep track of the number of Resistor objects that are dynamically created. This will also be used to limit the number of objects that are dynamically created to the maximum array size of the pointer array in the test function main().

In the Resistor constructor, use a random-number generator to randomly assign a nominal resistance value to the object between 1,000 and 10,000 ohms. The resistance values are not required to be standard resistance values.

Create an array of pointers of type Resistor.

Use elements of the pointer array to allow the user to dynamically allocate memory and to instantiate objects of the Resistor class.

Use the indirect member-selection operator (pointer) in the test routine to access function members of the Resistor class.

Write a new, nonclass function called in function main() to sort the pointers to the Resistor objects in order from lowest nominal resistance value to highest, passing a pointer to the Resistor-object pointer and the size as the only passed data arguments.

Display the sorted Resistor objects according to the nominal resistance value, from lowest to highest.

Within the sorting function, use pointer arithmetic to access the individual Resistor objects.

Function main() should also ensure that there are no memory leaks when the program ends.

Explanation / Answer

#include #include #include "stdafx.h" using namespace std; void Shuffle(bool baCardsDealt[]); void PrintCard(int iCard); int GetNextCard(bool baCardsDealt[]); void PrintScoresAndHands(int iaHouseHand[], int iaPlayerHand[], const int CardCount,int PrintHand); int main() { time_t qTime; time(&qTime); srand(qTime); bool baCardsDealt[52]; int DealerCardCount = 0; int DealerHand[12]; int PlayerCardCount = 0; int PlayerHand[12]; // Loop once for each hand while (true) { // "Shuffle" the cards; set them all to undealt Shuffle(baCardsDealt); // Deal the hands. Get two cards for each PlayerHand[0] = GetNextCard(baCardsDealt); DealerHand[0] = GetNextCard(baCardsDealt); PlayerHand[1] = GetNextCard(baCardsDealt); DealerHand[1] = GetNextCard(baCardsDealt); DealerCardCount = 2; PlayerCardCount = 2; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote