Skip to content

Rock paper scissors#2

Open
kristianjclark1 wants to merge 7 commits intomasterfrom
RockPaperScissors
Open

Rock paper scissors#2
kristianjclark1 wants to merge 7 commits intomasterfrom
RockPaperScissors

Conversation

@kristianjclark1
Copy link
Owner

No description provided.

Copy link

@daniefer daniefer left a comment

Choose a reason for hiding this comment

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

All this feedback is more of design feedback and less of functionality feedback. In programing there are 1000s of ways to solve the same problem. What separates good from great is making it easy to understand and change later. So keep up the good work!

//Console.ReadLine();
}

public static void GetInput()
Copy link

Choose a reason for hiding this comment

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

This methods does a lot more than just "get input". Try to keep your method names in sync with what they actually do. In this case, I would split this into a GetInput, PlaceMark (which you already have), CheckForEndGame, and TogglePlayer methods. Then in your Program.Main method, call them in the right order.

if (HorizontalWin() || VerticalWin() || DiagonalWin() == true)
{
Console.WriteLine("Player " + playerTurn + " Won!");
Environment.Exit(0);
Copy link

Choose a reason for hiding this comment

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

No need to call Environment.Exit here, just return true and your while loop should exit


}

public static bool CheckForTie()
Copy link

Choose a reason for hiding this comment

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

This method name says to me, "you can call me to determine if the game has ended in a tie". But what it is actually doing is checking if any spots remain unplayed. There is a distinctions there that could lead to trouble for someone else who does not know you wrote this method with the assumption it would always be called after checking for no wins.


public static bool CheckForTie()
{
if (board[0][0] != " " && board[0][1] != " " && board[0][2] != " " && board[1][0] != " " &&
Copy link

Choose a reason for hiding this comment

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

Good job!
To put it another way though, you want to check if there are any remaining unplayed spots. There is a way to do this with loops that might lend itself better to understanding what you are wanting to confirm vs checking every spot explicitly (by setting the next of each array). Just think about it some and if you have time to go back to this later, see if you can rework it.

Sort/Program.cs Outdated
//Sorting numbers from smallest to largest//
int[] numArray = { 23, 55, 99, 38, 65 };

for (int i = 0; i < numArray.Length - 1; i++)

Choose a reason for hiding this comment

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

This sort needs to work for any int[] I set this too. When you find yourself copying and pasting code to do something more than once that means you probably need a while loop. You need to be able to say, "sort this array of integers until all integers are sorted". Right now, if you attempt to sort the array [5, 4, 3, 2, 1] your output is not sorted.

Try to convert this into a loop that does just that, continue sorting until the array is sorted.

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.

2 participants