Skip to content

Added assignment for try catch#5

Open
PradeepITT wants to merge 3 commits intomainfrom
TryCatch-assignment
Open

Added assignment for try catch#5
PradeepITT wants to merge 3 commits intomainfrom
TryCatch-assignment

Conversation

@PradeepITT
Copy link
Owner

No description provided.

Copy link
Collaborator

@mukulpalol16 mukulpalol16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the file name from Try_Catch.cpp to something more specific to our use case.

Try_Catch.cpp Outdated
@@ -0,0 +1,73 @@
#include <iostream>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create separate files for better code structure

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Try_Catch.cpp Outdated
}
};

class AccidentHandler {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can have a better name for this class instead of AccidentHandler

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Try_Catch.cpp Outdated

class Car {
public:
void driveSafely(bool collision, bool brakeFailure) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there are more exceptions/reasons for car accidents, then it wouldn't be the correct approach to pass the boolean values through parameters. can think of a better approach where we can handle multiple exceptions.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

bool collision = false;
bool brakeFailure = true;

if (collision) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to figure out in which condition this code will process PersonInjuredException exception

@nitintayal008 nitintayal008 self-requested a review April 3, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants