Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write the Panel class per this Module. ( Write a class means to write an H and a CPP , named as the class
Write the Panel class per this Module. Write a class" means to write an H and a CPP named as the class is named. Test it with this testPanel.cpp:
ctestPanel.cpp Panel.cpp
#include
using namespace std;
#include "Panel.h
int main
Panel p;
paddButton;
paddButton;
paddButton;
paddButton;
if pareAnyLit cout
ERROR
;
if pisLit cout
ERROR
;
ppressX;
ppress;
ppress;
cout
EXPECTED:
;
cout "ACTUAL: p endl;
pclearY;
pclear;
cout
EXPECTED:
;
cout "ACTUAL: p endl;
cout
EXPECTED:
;
cout "ACTUAL: pgetFirstLit endl;
if pareAnyLit cout
ERROR
;
if pisLit cout
ERROR
;
if pisLit cout
ERROR
;
This will be the first full and complete "building block" in our elevator simulation.
Here are some hints:
In the stream insertion operator, use something like panel.buttonsiisLit to access the is it lit?" attribute Button at index i in the vector of Button objects owned by the parameter object panel
In the member functions, use an unsigned int in the forloops that traverse the vector of buttons, like this: for unsigned int i ; i host.buttons.size; i
In Panel::getFirstLit traverse the vector of buttons, looking only at the lit ones. Find the one with the lowest sequence number and return its label. If none are lit, return a blank string.
Note there is no need for a stream insertion operator for the Button class.
Compile like this commend line statement: you won't need it if the program running from the IDE but a driver program.
cstdctestPanel.cpp Panel.cpp Wall
Submit the Panel.cpp and Panel.h DON'T submit testPanel.cpp
For this course, any user defined classes will have the header file classnameh includes the class declaration only and the source file classnamecpp includes the member function implementation only. There will be another cpp file as the driver program including the main function.
Panel class declaration Panelh example
class Panel
struct Button
string label;
bool lit;
int sequence;
static int count;
;
vector buttons;
public:
void addButtonstring;
void pressstring;
void clearstring;
string getFirstLit const;
bool isLitstring const;
bool areAnyLit const;
friend ostream& operatorostream& const Panel&;
;
Panel class member function implementations will be in the Panel.cpp
Include all three files Panelh Panel.cpp and testPanel.cpp in the project and check if the outputs correct before submission. If there is any "ERROR" in the console output, make sure to correct your work before the submission.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started