You will be required to define a base class


Must work in C++ with visual studios 2008: 
Objective: Create a C++ console application that utilizes the core concepts of inheritance and pointers by creating a class and a program that tests important features of that class.

Overview: This lab will require you to use C++ class inheritance to define and use a resistor class derived from a base resistor class. The program will allow the user to specify resistor component types and values. 

You will be required to define a base class (ResistorClass) for a generic resistor device and a derived classes (FancyResistorClass) for specific resistor device type.

Resistor Class UML Diagram (# indicates a protected member): 

Class: ResistorClass 
# double *m_dptrRes
# char *m_sptrResName
+ int m_istResCounter (static) 
+ void DisplayResistor(void)
+ void EnterResistance (void)
+ ResistorClass( )
+ ResistorClass(char Name[], double nominalResistance, double Tolerance)
+ ~ResistorClass( ) 

Begin work on this program by first coding the Resistor Class class declaration. Then code and test the Resistor class constructor functions one at a time. Code and test the rest of the functions one function at a time. To avoid compiler complaints, comment out the member function prototypes in the Resistor Class declaration that have not yet been completed. 

specifications:
This is the default constructor. 
* You will need to create two dynamic arrays using the new operator. The first array will store the resistor values (nominal, tolerance, min and max) and the second array (a character array) will hold the resistor's name.

* The resistor array will have four elements. The values stored in the array will be of data type double. The values will be stored to the array in the following positions:
m_dptrRes[0] = the nominal resistance value
m_dptrRes[1] = the tolerance value
m_dptrRes[2] = the max resistance value
m_dptrRes[3] = the min resistance value

The nominal value should be initialized to 1000.0 and the tolerance value should be initialized to .10.

The minimum and maximum resistance should then be calculated using the nominal and tolerance variables. The formulas are:
Minimum Resistance = Nominal - Nominal * Tolerance
Max Resistance = Nominal + Nominal * Tolerance

* The user should be prompted to supply a name for the resistor. The value supplied by the user will be stored using the resistor's name pointer. To conserve memory the name array should allocate only enough room to hold the number of characters supplied by the user. You'll want the user's entry to be saved to a string variable using the getline function. Then you'll need to determine the number of characters in the string variable, allocate the required memory and copy the characters from the string variable to the pointer. This requirement is more for demonstration purposes than it is for practicality. Here is the essential code:

//get the user's input
string Name;
getline(cin, Name);

//get the number of characters in the string
int length = (int)Name.length(); 

//add one to account for the null character 
m_sptrResName = new char[length + 1]; 

//copy from Name to the pointer
strcpy_s(m_sptrResName, length + 1, Name.c_str()); 

The strcpy_s function performs a deep-copy of character array data. You could replace the strcpy_s function with a for/loop that performs a deep copy. The syntax for strcpy_s is as follows:

strcpy_s(char *Destination,
int numberOfElements,
char *Source);

* To keep count of the number of resistor objects in existence, be sure to increment the static variable m_istResCounter. 

* Be sure to include an output statement that displays the message "Default Constructor Called"

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: You will be required to define a base class
Reference No:- TGS0132018

Expected delivery within 24 Hours