Skip to content

Added assignment for try catch - #5

Open
PradeepITT wants to merge 3 commits into
mainfrom
TryCatch-assignment
Open

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

Conversation

@PradeepITT

Copy link
Copy Markdown
Owner

No description provided.

@mukulpalol16 mukulpalol16 left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread Try_Catch.cpp Outdated
@@ -0,0 +1,73 @@
#include <iostream>

Copy link
Copy Markdown
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
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Done

Comment thread Try_Catch.cpp Outdated
}
};

class AccidentHandler {

Copy link
Copy Markdown
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
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Done

Comment thread Try_Catch.cpp Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Done

Comment thread CarAccident.cpp
bool collision = false;
bool brakeFailure = true;

if (collision) {

Copy link
Copy Markdown
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