Better or Worse method?

to activate the function I did only 2 lines of code:

Fstring WonResult = BCGame.PrintGameSumary();
std::cout << WonResult << std:: endl;

Better or worse doing this way? Returning texts is a bad thing?

Well, you need to change the name of the PrintGameSummary method because it doesn’t print.

If you are looking for compactness, try something like

std::cout << BCGame.GameSummary() << std::endl;

I think there is a bigger question though.

The FBullCowGame class, so far, has no input-output at all. That is, it is independent of the interaction with the user and it doesn’t even reflect what language the interaction is in, or how the interaction is happening. It could well be display in a GUI. It could even be that a computer program for guessing secret words is being operated.

Now, that is not the kind of thing we have been talking about except that FBullCowGame is described as providing a Model that is part of a MVC (Model-View-Controller) pattern. This is the kind of separation that is made in that pattern. It makes FBullCowGame a reusable component wherever this game is included in a program. In particular, we can continue to make all manner of changes to main.cpp and even add more files to the project without having to touch FBullCowaGame.hpp and FBullCowGame.cpp.

For all of these reasons, I recomnmend following the instructor’s lead and adding the PrintGameSummary() function to main.cpp.

PS: The VC part of the MVC pattern is sort of smeared together in main.cpp. There is a way to make a pretty-complete separation in that direction too, with main.cpp having the C part (technically the middle of the pattern but MCV is not the lingo [;<). From the Section 2 Lecture Titles, I don’t think we are going to dig into that. It might not be useful in preparing for use of the Unreal Engine.

1 Like

Thank you, I appreciate it.

Very nice reply!
Since you sound somewhat knowledgeable and I’m rather noobish on all that, I’d really appreciate if you commented on the way I tried to split these things in my version…
All the printing is indeed done by one separate “View” class, however I’m not all that clear on the separation of roles for the “Control” part, and perhaps the kind of interaction I designed is too naive and becomes impractical quickly.
Anyway, here’s the thing:

Privacy & Terms