-
Couldn't load subscription status.
- Fork 22
Add files via upload #17
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
Open
cmg2213
wants to merge
2
commits into
CPRO-Session1:master
Choose a base branch
from
cmg2213:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| For this project, I made a single player version of yahtzee that prints the dice, allows you to chose the dice you want to reroll, and rerolls them. It then lets you chose which category you want to put the total of the dice into, and stores those numbers on the scorecard, which it reprints as the updated version. | ||
| There were several differences from the original version that I proposed in the proposal. | ||
| In the proposal, I was going to make the scorecard a large data structure with sections for the score and the category name. I realized though that it would be more effective to have an array, and i made a two dimensional array with the categories and numbers that I updated every time. | ||
| The biggest problem though was that I was not able to figure out how to make my scoring function work. Why I tried originally to do was send a variable through the various functions to everntually reach the scoring function, and update that score. | ||
| This did not work, as I realized that I couldn't pass a variable through multiple functions. I then tried passing a pointer. If I had had more time to work, I might have figured out how to make it work by passing pointers through the functions to eventually reach the score function, but I was not able to make that work becuase I didn't realize I needed it until it was almost due. | ||
| The part that does work well though is the scorecard and dice rolling parts. In order play, you would enter the die you want to reroll, hit enter, enter the next number, and as many times as you want until you want to finally roll, when you hit 6 and hit enter. | ||
| This will run 13 times (one for every category on the scorecard), and if it worked it would print out the final score correctly, but because I could not get the pointers to work, I instead made it complie and run, even if it doesn't work fully. | ||
| To compile and run it, type "gcc yahtzee2.c -o final" and to run it would be "./final" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| Caleb Gershengorn | ||
|
|
||
| Final project: | ||
| For my final project, I want to code the game yahtzee in C. | ||
| While I am not sure it would utilize pointers, it would absolutely involve all previous topics we have learned. | ||
| For the scorecard, I would use a data structure with two parts, the name of the category and the score for each category. | ||
| I would print out this scorecard every turn, printing the updated data structure. | ||
| This data structure would look something like: | ||
| typedef struct{ | ||
| char category[100]; | ||
| int score; | ||
| }scores; | ||
|
|
||
| I would then create three arrays, one for the scores, one for the categories, and one for the dice. | ||
| For the dice, it would be an array of 5 random numbers 1-6 that the user would be able to update in a dicerolling function to be called later on. | ||
| int board[]=[five random numbers]; | ||
| for the categories, there would be a array of 13 numbers, and each time a category was picked, the number would be placed in the array and would make sure that that number cannot be used again by checking that array. | ||
| int CategoryList[13]; | ||
| for the score, i could use either an array or a constantly updating variable to just have scores added to it to sum up the total scores and print it at the end. | ||
|
|
||
| I would also need to create a set of functions to test whether a set of dice fulfills the qualifications for a certain type of roll (full house, straight, etc.) | ||
| I would do this by looping through the board array and just checking whether the needed dice are there, and returning 1 or zero. | ||
| I would then have a pair of larger functions, one to deal with the score and one to deal with the scorecard. First, the dicerolling function would call the scorecard function, which would check if the category chosen is already filled and would call the checking function (where applicable) to decide whether it is valid or not. | ||
| Once the scorecard function has checked the user's choice, it would call the score function, which would add the given to it from the scorecard function to the score variables and update the player's total score. | ||
| The final function would be the dicerolling function. It will print out the dice, and ask the player which dice to reroll, with a feature built in to avoid the user entering a character other than a number 1-6 | ||
| it will run inside a loop thrice, to simulate the three rolls the player gets, and the function runs 13 times, once to fill each category. | ||
| Then, the main function would only need to create the arrays of categories and score and dice, so that they can be used in the whole program. | ||
| After the diceroll function runs out, then it prints the total score by adding all the terms in the score array. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sounds solid! You don't necessarily need to use pointers, so that's fine!