Denis, read carefully Junilu's posts. I remember when I read similar ones by him few years back, it clicked me at some point how picking names very
carefully leads you towards the code along with the problem which are easier to understand and solve.
Have a look at this one. Does really the game supposed to worry about player's name? I'm doubted. I'd naturally think it supposed to be in Computer
class, but by now you figured that Player
, what Junilu suggested most likely is the best name to give to this class. I called it an Opponent
initially. Do you see how an opponent is much poorer name than Player
? Opponent means that there is a player who plays against, which is true in most cases, but what is not, what if two players play together towards some common goal, so that gives an ability to re-think your strategy whether you really want to go that route? Have you ever heard saying that Team consists of 11 opponents? No! They say team consists of 11 players who play against 11 players. As you see naming is really fundamental thing, so when you look at your code it makes sense, you need to get it right - to name things what they actually mean, represent.
So try to clean up your current code by renaming things and putting information in the right places. I guess your design will read way nicer, it is not about the beauty though, it is about doing "things right"
. Whether it be your personal little project or school assignment.