-
Notifications
You must be signed in to change notification settings - Fork 3
Jinnujohnson #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Jinnujohnson #4
Changes from all commits
b70fc12
06b6d3f
5095519
7cc1f07
c1f22f6
5ce8877
5dc0bd9
0e39d3f
454c21d
4c55a1b
7fb3218
5073293
e0b01f4
8add877
e6f420e
1a8a57f
37b53cb
2ce51b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* Square generating program */ | ||
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| class Square | ||
| { | ||
| private: | ||
| int column,row,side; | ||
|
|
||
| public: | ||
| void square_generate(int temp_side) | ||
| { | ||
| side = temp_side; | ||
|
|
||
| if(cin) | ||
| { | ||
| try | ||
| { | ||
| if(side < 1) | ||
| throw side; | ||
| else if(side == 1) | ||
| top_bottom_side(side); | ||
| else | ||
| square_draw(side); | ||
| } | ||
|
|
||
| catch(int errorVariable) | ||
| { | ||
| cerr << "Error: Invalid data. Expected positive integer!\n"; | ||
| } | ||
| } | ||
| else | ||
| cerr << "Error: Wrong Data!" << endl; | ||
| } | ||
|
|
||
| void top_bottom_side(int temp) | ||
| { | ||
| for(column = 1; column <= temp; column++) | ||
| cout << '#'; | ||
| cout << "\n"; | ||
| } | ||
|
|
||
| void left_right_side(int temp) | ||
| { | ||
| for(row = 1; row <= temp - 2; row++) | ||
| { | ||
| cout << '#'; | ||
| for(column=1; column <= temp - 2; column++) | ||
| cout << " "; | ||
| cout << '#'; | ||
| cout << "\n"; | ||
| } | ||
| } | ||
|
|
||
| void square_draw(int draw_variable) | ||
| { | ||
| top_bottomSide(draw_variable); | ||
| left_rightSide(draw_variable); | ||
| top_bottomSide(draw_variable); | ||
| } | ||
| }; | ||
|
|
||
| int main() | ||
| { | ||
| int side; | ||
| Square square; | ||
| cout << "Enter side of Square Box\n"; | ||
| cin >> side; | ||
| square.square_generate(side); | ||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* Program to illustrate drawing of a Square using Object and Class in C++ Programming */ | ||
|
|
||
|
|
||
| #include <iostream> | ||
| #include "Square.cpp" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be a line before |
||
| using namespace std; | ||
|
|
||
| int main() | ||
| { | ||
| int side; | ||
| char symbol; | ||
| cout << "Enter Symbol to draw\n"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a separate function to accept input. |
||
| cin >> symbol; | ||
| cout << "Enter side of Square Box\n"; | ||
| cin >> side; | ||
| Square square; | ||
| square.square_generate(symbol,side); | ||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /*Program illustrates the drawing of a Square Box in C++ programming*/ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try not to use obvious comments. If you really have to use it, make it very short & simple. Consider:
|
||
|
|
||
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| class Square | ||
| { | ||
| private: | ||
| int column, row, side; | ||
| char symbol; | ||
|
|
||
| public: | ||
| void square_generate(char function_symbol,int function_side) | ||
| { | ||
| symbol = function_symbol; | ||
| side = function_side; | ||
|
|
||
| if(cin) | ||
| { | ||
| try | ||
| { | ||
| if(side < 1) | ||
| throw side; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider indenting the statements of the preceding |
||
| else if(side == 1) | ||
| top_bottom_side(side); | ||
| else | ||
| square_draw(side); | ||
| } | ||
|
|
||
| catch(int errorVariable) | ||
| { | ||
| cerr << "Error: Invalid Input. Expected Positive Integer!\n"; | ||
| square_draw(3); | ||
| } | ||
| } | ||
| else | ||
| cerr << "Error: Confirm Both Values Are Inserted or Wrong Data!"; | ||
| } | ||
|
|
||
| void top_bottom_side(int temp) | ||
| { | ||
| for(column = 1; column <= temp; column++) | ||
| { | ||
| cout << symbol; | ||
| } | ||
| cout << "\n"; | ||
| } | ||
|
|
||
| void left_right_side(int temp) | ||
| { | ||
| for(row = 1; row <= temp - 2; row++) | ||
| { | ||
| cout << symbol; | ||
| for(column=1; column <= temp - 2; column++) | ||
| { | ||
| cout << " "; | ||
| } | ||
| cout << symbol; | ||
| cout << "\n"; | ||
| } | ||
| } | ||
|
|
||
| void square_draw(int draw_variable) | ||
| { | ||
| top_bottom_side(draw_variable); | ||
| left_right_side(draw_variable); | ||
| top_bottom_side(draw_variable); | ||
| } | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check indentation.