Skip to content

Conversation

@gitmajo
Copy link
Collaborator

@gitmajo gitmajo commented Feb 24, 2019

  • ostream overloaded operator added (please check if it is placed in proper place, or if it should be friend)
  • few methods were renamed to better present their purpose

majkel-space and others added 24 commits February 21, 2019 10:33
@codecov
Copy link

codecov bot commented Feb 24, 2019

Codecov Report

Merging #28 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #28   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           6      6           
  Lines         134    136    +2     
=====================================
+ Hits          134    136    +2
Impacted Files Coverage Δ
src/DisplayBoard.cpp 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d0edb2...582d8f1. Read the comment docs.

@gitmajo
Copy link
Collaborator Author

gitmajo commented Mar 1, 2019

Branch US3.2 was updated to current state on US2.2.
Ostream operator might be alternatively used to dislay().
It is not "must have", but lets keep it for training purposes.

std::string compareBoard = " +--+\n | |\n+--+--+\n| |??|\n+--+--+\n";

testing::internal::CaptureStdout();
std::cout << board;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm unable to reproduce this feature in main.cpp by simple writing down code as below:

#include "Board.hpp"
...
    Board board(1, 1, {{1}}, {{1}});
    std::cout << board;

I got error:
error: no match for ‘operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}’ and ‘Board’)

Could you look into it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I moved declaration to board.hpp, but I still prefer to keep definition in DisplayBoard.cpp

Copy link
Collaborator

Choose a reason for hiding this comment

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

What use is to keep it in Displayboard when you can't use it?

Copy link
Collaborator Author

@gitmajo gitmajo Mar 2, 2019

Choose a reason for hiding this comment

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

My intention was to keep definition and declaration in displayBoard.hpp / .cpp because it is completely connected to display functionality. I know that you prefer to include only in main board.hpp, so I moved definition of ostream operator to board.hpp.
From on site it would be clear to have declaration and definition in corresponding files (name.cpp & name.hpp).
On the other hand why not to "hide" definition it in DisplayBoard.cpp and do not "litter" Board.cpp.
@LordLukin what is your opinion?

@jzych
Copy link
Collaborator

jzych commented Mar 2, 2019

Why this PR wants to merge this branch into US2.2 instead of master?

@gitmajo gitmajo changed the base branch from US2.2 to master March 2, 2019 11:47
@gitmajo
Copy link
Collaborator Author

gitmajo commented Mar 2, 2019

Why this PR wants to merge this branch into US2.2 instead of master?

I set US2.2 as a base to present only changes between US2.2 and US3.2, but I didn't know that it will mean merging from US3.2 to US2.2. You are right, changed.

@gitmajo gitmajo requested review from jzych and ziobron March 2, 2019 12:13
Copy link
Collaborator

@jzych jzych left a comment

Choose a reason for hiding this comment

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

Looks good, only thing is that overload definition shouldn't also be in Board.cpp?

Copy link
Owner

@ziobron ziobron left a comment

Choose a reason for hiding this comment

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

Is this operator<< really needed? Will it be used anywhere? Right now it isn't.
You can always call cout << display(b); when you need to have it on screen.

@ziobron ziobron self-requested a review March 4, 2019 22:15
void display() const;
};

std::ostream& operator<<(std::ostream& os, const Board& b);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it outside of the Board class? I think that task clearly describes that: Overloaded ostream operator for Board - which in my opinion mean that this should be in the class definition.

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.

7 participants