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

Trying to build a filter class: The Filter class should have, at a minimum, the

ID: 440227 • Letter: T

Question

Trying to build a filter class: The Filter class should have, at a minimum, the following capabilities. a resistor-object data member a capacitor-object data member a cutoff frequency (in Hertz) of the RC filter maximum and minimum cutoff frequencies, based on the maximum and minimum in-tolerance values of the capacitor and the resistor object a filter type, either low pass or high pass allow the user to enter new values for the filter, including 6.1. resistor tolerance and nominal resistance; 6.2. capacitor tolerance and nominal capacitance; and 6.3. filter type provides the ability to write all capacitor, resistor, and filter data members to a formatted text file and allows the user to name the file provides the ability to read all capacitor, resistor, and filter data members from a formatted text file and allows the user to enter the file name and correctly handles a file-not-found error This is what i have so far Errors are listed below :worklabsweek3week 4 ilter.cpp(24): error C2065: 'r1' : undeclared identifier 1>c:worklabsweek3week 4 ilter.cpp(24): error C2228: left of '.setNom' must have class/struct/union 1> type is ''unknown-type'' 1>c:worklabsweek3week 4 ilter.cpp(26): error C2065: 'r1' : undeclared identifier 1>c:worklabsweek3week 4 ilter.cpp(26): error C2228: left of '.setTol' must have class/struct/union 1> type is ''unknown-type'' 1>c:worklabsweek3week 4 ilter.cpp(28): error C2065: 'c1' : undeclared identifier 1>c:worklabsweek3week 4 ilter.cpp(28): error C2228: left of '.setCapacitance' must have class/struct/union 1> type is ''unknown-type'' 1>c:worklabsweek3week 4 ilter.cpp(30): error C2065: 'c1' : undeclared identifier 1>c:worklabsweek3week 4 ilter.cpp(30): error C2228: left of '.setCapTolerance' must have class/struct/union 1> type is ''unknown-type'' Filter.cpp #include "Filter.h" #include#include Filter::Filter(void){}//added Filter::Filter( double initialNominalR, double initialToleranceR, double initialNominalC, double initialToleranceC) { FiltRes.setNom(initialNominalR); FiltRes.setTol(initialToleranceR); FiltCap.setCapacitance(initialNominalC); FiltCap.setCapTolerance(initialToleranceC); } Filter::Filter(Resistor initialR, Capacitor initialC) // :FiltRes(initialR),FiltCap(initialC) { r1.setNom(initialR.getNom( ) ); r1.setTol(initialR.getTol( ) ); c1.setCapacitance(initialC.getCapacitance( ) ); c1.setCapTolerance(initialC.getCapTolerance( ) ); } /*Filter::~Filter() { }*/ double Filter::getCutOffFrequency(void) { if(FiltRes.getNom()==0 &&FiltCap.getCapacitance()==0) return 0; else{ return (1 / (2 * PI * FiltRes.getNom( ) * FiltCap.getCapacitance( )/1000000 )); } }

Explanation / Answer

HRESULT FilterAckClass( LPCWSTR wszQueueFormatName, unsigned short usAckClass ) { // Validate the input string. if (wszQueueFormatName == NULL) { return MQ_ERROR_INVALID_PARAMETER; } // Define the required constants and variables for the filter. const int NUMBEROFPROPERTIES = 5; // Number of properties DWORD cPropId = 0; // Property counter //Define an MQMSGPROPS structure. MQMSGPROPS msgprops; MSGPROPID aMsgPropId[NUMBEROFPROPERTIES]; PROPVARIANT aMsgPropVar[NUMBEROFPROPERTIES]; HRESULT aMsgStatus[NUMBEROFPROPERTIES]; HANDLE hQueue = NULL; // Queue handle HANDLE hCursor = NULL; // Cursor handle HRESULT hr = MQ_OK; // Define results DWORD dwRecAction = 0; // Receive action mode // Specify the message properties to be retrieved. aMsgPropId[cPropId] = PROPID_M_CLASS; // Property ID aMsgPropVar[cPropId].vt = VT_UI2; // Type indicator cPropId++; // Initialize the MQMSGPROPS structure. msgprops.cProp = cPropId; // Number of message properties msgprops.aPropID = aMsgPropId; // IDs of message properties msgprops.aPropVar = aMsgPropVar; // Values of message properties msgprops.aStatus = aMsgStatus; // Error reports // Open the queue to filter messages. hr = MQOpenQueue( wszQueueFormatName, // Format name of the queue MQ_RECEIVE_ACCESS, // Access mode MQ_DENY_RECEIVE_SHARE, // Share mode &hQueue // OUT: Queue handle ); if (FAILED(hr)) { return hr; } // Create the cursor used to navigate through the queue. hr = MQCreateCursor( hQueue, // Queue handle &hCursor // OUT: Cursor handle ); if (FAILED(hr)) { MQCloseQueue(hQueue); return hr; } // Peek at the first message in the queue. hr = MQReceiveMessage( hQueue, // Queue handle 0, // Maximum time (msec) MQ_ACTION_PEEK_CURRENT, // Receive action &msgprops, // Message property structure NULL, // No OVERLAPPED structure NULL, // No callback function hCursor, // Cursor handle NULL // No transaction ); if (FAILED(hr)) { MQCloseCursor(hCursor); MQCloseQueue(hQueue); return hr; } // Filter messages from the queue. do { if (msgprops.aPropVar[0].uiVal == usAckClass) { dwRecAction = MQ_ACTION_RECEIVE; // Receive action hr = MQReceiveMessage( hQueue, // Queue handle 0, // Maximum time (msec) dwRecAction, // Receive action &msgprops, // Message property structure NULL, // No OVERLAPPED structure NULL, // No callback function hCursor, // Cursor handle NULL // No transaction ); if (FAILED(hr)) { break; } // // Process the acknowledgment message. // dwRecAction = MQ_ACTION_PEEK_CURRENT; // Reset to peek at the current cursor position. } else { dwRecAction = MQ_ACTION_PEEK_NEXT; // Reset receive action mode. } hr = MQReceiveMessage( hQueue, // Queue handle 0, // Maximum time (msec) dwRecAction, // Receive action &msgprops, // Message property structure NULL, // No OVERLAPPED structure NULL, // No callback function hCursor, // Cursor handle NULL // No transaction ); if (FAILED(hr)) { break; } } while (SUCCEEDED(hr)); // Close the cursor and queue to free resources. hr = MQCloseCursor(hCursor); if (FAILED(hr)) { MQCloseQueue(hQueue); return hr; } hr = MQCloseQueue(hQueue); return hr; }