Question: SHOW IDE HAS TO SHOW OUTPUTTED CODE FAST / BEST ANSWERS LIKED ! In DeskTop.h Declare two exception classes: NoPowerException. This exception will be thrown
SHOW IDE
HAS TO SHOW OUTPUTTED CODE
FASTBEST ANSWERS LIKED
In DeskTop.h
Declare two exception classes:
NoPowerException. This exception will be thrown when the user turns on a computer that does not connect to power outlet. This
class is an empty class.
LackComponentException. This exception will be thrown when the user turns on a computer that does not have a RAM, a hard drive,
or a video card. This class has a private string variable, missingComponent, and a public accessor getMissingComponent that will
return the value stored by this variable. The class also has two constructors: a default constructor that sets missingComponent as
"essential components"; an overloaded constructor that take a parameter of string as input and set the value of missingComponent
In DeskTop.cpp
Provide the implementation of the member functions of the LackComponentException class.
Complete the turnOn function of the DeskTop class. This function will first check whether any of the three boolean variables, RAM,
hardDrive, videoCard is false. If one or more of these variable values are false a LackComponentException exception initial ized
with a string encoding the missing component information will be thrown. For example, if only RAM is false, the string is "RAM", and if
only hardDrive is false, the string is "hard drive". If both RAM and hardDrive are false, the string will be "RAM, hard drive", and if all three
variables are false, the string will be "RAM, hard drive, video card". If all the above variables are true, the function will check whether
the power is provided. If there is no power ie powerfalse a NoPowerException is thrown.
In main.cpp
Complete the main function to handle the potential exceptions thrown when turning on a desktop computer. Specifically, after a DeskTop
computer is created based on user input, the computer will be turned on If a LackComponentException object is thrown and caught, the
program will output the following message
Exception: No missing component
If a NoPowerException object is thrown and caught, the program will output the following message
Exception: power is not on please check your connection to power outlet.
Ex: if the user enters
the program will output
Exception: No RAM, video card!
if the user enters
the program will output
Computer is starting
Current file: main.cpp
#include "DeskTop.h
int main
int hasRAM, hasHardDrive, hasVideoCard, hasPower;
cin hasRAM hasHardDrive hasVideoCard hasPower;
TODO: put the following code into the proper exception handling to handle the potential exceptions
DeskTop computerhasRAM hasHardDrive, hasVideoard hasPower;
computerturnOn;
return ;
return ;
Current file: DeskTop.h
Current file: DeskTop.cpp
#include "DeskTop.h
TODO: Implement the member functions of the LackComponentException class
void DeskTop: :turnOn
TODO: complete the implementation of the turnOn function to handle different exception cases
cout "Computer is starting endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
