Question
C++ exceptions problem. PLEASE show 3 files!!!!!! main.cpp flashdrive_3_0.h flashdrive_3_0.cpp Background: Exception handling is a very important part of being an object-oriented programming. Rather returning
C++ exceptions problem.
PLEASE show 3 files!!!!!!
main.cpp
flashdrive_3_0.h
flashdrive_3_0.cpp
Background: Exception handling is a very important part of being an object-oriented programming. Rather returning some kind of int return value every time you tickle an object, C++ programmers expect methods to focus on their task at hand. If something bad happens, C++ programmers expect methods to throw exceptions. When caught, exceptions can be processed. When uncaught, they cause a program to terminate dead in its tracks. The typical pattern in this course is to have class code throw exceptions and driver code catch them. Because of exceptions, when writing client driver code, our try blocks will not be polluted with error processing statements.
part_a: flashdrive 3.0 (exceptions)
The purpose of this assignment is to work with exceptions. As you may recall, I have provided you with a sample class named FlashDrive which has been diagrammed below. I'd like you to enhance this class so that invoking its methods or operators potentially throw exceptions, rather than just printing error messages to cout. Currently, our favorite exception class is std::logic_error. You can create a logic_error by passing a string value to its constructor. Officially, you should also say #include
Although the sample driver code might not code for all these circumstances, I would like you to throw exceptions when:
more stuff has been put onto the drive than it can safely hold (due to writeData)
a negative number is potentially used as a my_StorageUsed value (due to operator or bad values being sent to the constructor call)
a negative number is potentially used as a my_StorageCapacity value (due to operator or bad values being sent to the constructor call)
So carefully wind your way thru all the operators and methods of the class ensuring that logic_error gets thrown in each of these circumstances.
I'd also like you to get operator << and operator >> working for the class FlashDrive.
|
|
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