-
Couldn't load subscription status.
- Fork 22
final project proposal #13
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
yaelkelmer
wants to merge
6
commits into
CPRO-Session1:master
Choose a base branch
from
yaelkelmer: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
6 commits
Select commit
Hold shift + click to select a range
530d907
final project proposal
yaelkelmer 150dd59
almost done
yaelkelmer 6d0b231
final project
yaelkelmer 12f7d4f
I accidentally deleted an opening bracket and didn't realize
yaelkelmer c9d1b4e
COMS 4156 HW0 - added comment
8d8610d
Merge pull request #1 from yaelkelmer/coms4156
yaelkelmer 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 |
|---|---|---|
| @@ -1,46 +1,11 @@ | ||
| # Final Project | ||
| Yael Kelmer's README file. | ||
|
|
||
| ## Objectives | ||
| To review and implement concepts learned from class in a self-designed program. | ||
| To run my code you just need to type: ./finalproject | ||
|
|
||
| ### Description | ||
| You will design, propose, and implement a project of your own choosing. Your project must implement or include each of the following concepts: | ||
| - Variables/data types | ||
| - Input/output | ||
| - Conditional statements | ||
| - Loops | ||
| - Functions | ||
| - Arrays/strings (either directly or as a pointer) | ||
| - Advanced data types (structures and enumerated lists) <br> | ||
| My final project recreates the card game SET. This is how the game works: There will be 9 cards displayed on your screen. Each card has 3 characteristics: a number(1, 2, 3), a fill(e (empty), f (full), s (striped) ), and a shape(c (circle),s (square), t (triangle) ). These cards can be combined to form a SET. What is a SET you may ask? A SET is three cards, where each characteristic, when looked at individually, is either all the same OR all different. For example, a SET, would be three cards who have all different numbers, all different fills, and all the same shape. Your goal is to find as many SETs as you can! When you spot a set type in the location of each card (the location is the number next to the description of the card). If you think thereare no SETs on the board, you can request more cards. | ||
|
|
||
| If it is appropriate to use a header file and/or an external .c file containing utility functions, you should do so. If you have more than a few functions in your program, this applies to you. | ||
| The code uses a struct to create the characteristics of the card, which are number, fill, and shape. The code uses 5 functions that I created. These functions generate the deck of cards, shuffle the cards, display the cards on the board, display the necessary cards on the board, and check if the 3 cards that the user selected are in fact a set. Within int main() I use the functions that create the deck of cards and shuffles them. Then I explain the rules of the game to the user. After the user says they are ready, 9 cards are displayed on the board. The user has the option to add more cards (in case there are no SETs on the board) as long as there are more cards in the deck that are available. If the user would like more cards, then 3 more cards are printed on the screen. The user then inputs the locations of the three cards that they think are a set and the code utilizes the function that checks if three cards are a set to check. If it is a SET then the user is told it is a SET and if it is not, the user is told it is not a SET. Once there are no more cards in the deck and all the cards are displayed on the board, the user is asked if they want to stop the game. If they feel that there are no more sets they can say yes and the game stops. If they feel that there are more sets they can continue to play and they will continue to be prompted to stop the game. | ||
|
|
||
| Your program must be well-commented and provide the user with information on how to use your program. Interaction with the program should be specified within the program as well as within a readme.txt document. Rules for games should also be included in the readme.txt document. | ||
| Additionally, your code must be written efficiently and handle invalid user input appropriately. This means that if you have the user enter a number, and the user enters a string or a character, your program should not crash, go into an infinite loop, or produce anything outside of the expected functionality. | ||
| In my proposal I said that I would use UNICODE characters to display the cards. However, as I was coding I realized that I did not know how to implement it, so I displayed the cards in a different manner. | ||
|
|
||
| Examples of projects include (but are not limited to): game simulators (board games, battle arena, other games), text adventure games, artificial intelligence applications, etc. | ||
|
|
||
| Note: There may be functionality you wish to include in your project that we have not gone over yet in class. You can check with your instructor (me) or your TA (Lesley) to see if we intend to go over it or if it is possible. You may wish to temporarily hardcode data, functionality, etc. until we go over it. Your final code for those sections should not be hardcoded. | ||
|
|
||
| ### Part 1: Proposal | ||
| You must submit a proposal that details the following: | ||
| - Descriptive overview of project (what it does, what game it implements/simulates, etc). This should be long enough to explain what your program is and what it does/does not do. | ||
| - Detailed examples of concept implementation (an example each of how you will use functions, loops, etc.). You do not need to explain how you will use variables or input/output unless it is not inherently obvious. | ||
| - Your reasons for picking this project (you are interested in game design and wanted to create a game, you think the application is interesting and why, etc.). | ||
| - Any external libraries you are considering using and what you will use them for. Keep in mind that most of your code should be your own, and we cannot provide any help for external libraries. This includes graphics libraries. You are responsible for learning and figuring them out on your own. Also detail any code you will use that is not yours. | ||
|
|
||
| ### Part 2: Project Implementation | ||
| You must implement the project as described in your proposal and conforming to the expectations in the Description section. | ||
|
|
||
| Functions and large code blocks should be documented (have comments briefly explaining their purpose, as well as any parameters or return values, if applicable). | ||
|
|
||
| You must include a readme.txt detailing how to run your project, a brief overview of what it does, and a brief explanation of interaction with the program (e.g. “You may enter commands at the >> prompt. For help/suggestions of commands to enter at any time, type ‘help’.” for a text adventure game). If your project is a game or game simulator, you should also include any rules as applicable (e.g. “Go Fish is a game of matching cards. If you suggest a card your opponent has, he/she must give you that card. Likewise, if the opponent asks for a card you have, you must give him/her that card. If no card matches, player draws from the pile. Otherwise, players continue asking for cards until they ask for a card no one has.”). | ||
|
|
||
| Your readme.txt should also detail any changes made that do not follow your original proposal and explain why they differ. | ||
|
|
||
|
|
||
| ### Deliverables | ||
| Your proposal should be submitted by 10am on Monday, July 11, 2016. It will either be approved or modification requested by Monday night. Note that if you submit your proposal early, it will likely be evaluated early, and you will be able to begin work on your project as soon as it is approved. Your proposal should be in a .doc, .pdf, or .txt document. | ||
|
|
||
| Your project is due Friday, July 15, 2016 at 4pm. Please submit ALL files (source code, external libraries, data files, and executable). | ||
|
|
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,197 @@ | ||
| /* Yael Kelmer. */ | ||
| /* Comment for COMS4156 */ | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <time.h> | ||
|
|
||
| typedef struct { | ||
| int number; | ||
| char fill; | ||
| char shape; | ||
| } card; /*this is the struct that formats a card */ | ||
|
|
||
| /*this function generates the deck of cards for SET and puts them in an array */ | ||
| void generateDeck (card arrayCards[]) { | ||
| int counter = 0; | ||
| int number; | ||
| int fill; | ||
| int shape; | ||
| char fillArray[] = {'e', 's', 'f'}; | ||
| char shapeArray[] = {'t', 's', 'c'}; | ||
| for (number = 0; number < 3; number++) { | ||
| for (fill = 0; fill < 3; fill++) { | ||
| for (shape = 0; shape < 3; shape++) { | ||
| card a = {number, fillArray[fill], shapeArray[shape]}; | ||
| arrayCards[counter] = a; | ||
| counter++; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /*this function shuffles the deck of cards so that the player is not playing the same game if he or she chooses to play more than once */ | ||
| void shuffleCards (card arrayCards[]) { | ||
| int i; | ||
| int rand1; | ||
| int rand2; | ||
| card placeHolder; | ||
| srand(time(NULL)); | ||
| for (i = 0; i < 100; i++) { | ||
| rand1 = rand() % 27; | ||
| rand2 = rand() % 27; | ||
| placeHolder = arrayCards[rand1]; | ||
| arrayCards[rand1] = arrayCards[rand2]; | ||
| arrayCards[rand2] = placeHolder; | ||
| } | ||
| } | ||
|
|
||
| /*this function displays a card */ | ||
| void displayCard (card a) { | ||
| printf ("{%d, %c, %c} ", a.number, a.fill, a.shape); | ||
| } | ||
|
|
||
| /*this function prints the cards on the board such that there are only three in a row */ | ||
| void cardsOnBoard (card arrayCards[], int display) { | ||
| int i; | ||
| int counter = 0; | ||
| for (i = 0; i < display; i++) { | ||
| printf ("%d: ", i); | ||
| displayCard(arrayCards[i]); | ||
| counter++; | ||
| if (counter == 3) { | ||
| printf ("\n"); | ||
| counter = 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /*this function checks if the three cards that the user selected do in fact make a set */ | ||
| int checkSet (card a, card b, card c) { | ||
| int check = 0; | ||
|
|
||
| if (a.number != b.number && a.number != c.number && b.number != c.number) { | ||
| check++; | ||
| } | ||
| else if (a.number == b.number && a.number == c.number) { | ||
| check++; | ||
| } | ||
| else { | ||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| if (a.fill != b.fill && a.fill != c.fill && b.fill != c.fill) { | ||
| check++; | ||
| } | ||
| else if (a.fill == b.fill && a.fill == c.fill) { | ||
| check++; | ||
| } | ||
| else { | ||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| if (a.shape != b.shape && a.shape != c.shape && b.shape != c.shape) { | ||
| check++; | ||
| } | ||
| else if (a.shape == b.shape && a.shape == c.shape) { | ||
| check++; | ||
| } | ||
| else { | ||
| return 0; | ||
| } | ||
|
|
||
| return check; | ||
| } | ||
|
|
||
| int main () | ||
| { | ||
| card arrayCards[27]; | ||
| int display = 9; | ||
| int available = 27; | ||
| int amountOfSets = 0; | ||
| generateDeck (arrayCards); | ||
| shuffleCards(arrayCards); | ||
|
|
||
| printf ("Welcome to SET! This is how the game works: There will be 9 cards displayed on your screen. Each card has 3 characteristics: a number(1, 2, 3), a fill(e (empty), f (full), s (striped) ), and a shape(c (circle), s (square), t (triangle) ). These cards can be combined to form a SET. What is a SET you may ask? A SET is three cards, where each characteristic, when looked at individually, is either all the same OR all different. For example, a SET, would be three cards who have all different numbers, all different fills, and all the same shape. Your goal is to find as many SETs as you can! When you spot a set type in the location of each card (the location is the number next to the description of the card). Type the first number then press enter, type the second number then press enter, and lastly type the third number then press enter. If you think there are no SETs on the board, you can request more cards. If you are readytype 'g' and press enter. Good luck!\n"); | ||
| char ready; | ||
| scanf (" %c", &ready); | ||
| if (ready == 'g' || 'G') | ||
| { | ||
| while (1) { | ||
| printf ("These are the cards on the board:\n"); | ||
| cardsOnBoard(arrayCards, display); | ||
| /*this conditional statement asks the user if they want more cards as long as there are still more cards available. if the user says yes, more cards are added. */ | ||
| if (display < available) { | ||
| printf ("\n"); | ||
| printf ("Do you want more cards (Y/N): "); | ||
| char moreCards; | ||
| scanf (" %c", &moreCards); | ||
| if (moreCards == 'Y' || moreCards == 'y') { | ||
| display += 3; | ||
| if (display >= available) { | ||
| display = available; | ||
| } | ||
| printf ("These are the cards on the board:\n"); | ||
| cardsOnBoard(arrayCards, display); | ||
| } | ||
| else if (moreCards == 'N' || moreCards == 'n') { | ||
| } | ||
| else { | ||
| printf ("\nThat is not a yes or no answer, so I am assuming that is a no.\n"); | ||
| } | ||
| } | ||
| printf ("\n"); | ||
| printf("Which three cards do you think make a set?\n\n"); | ||
| int a; | ||
| int b; | ||
| int c; | ||
| scanf ("%d %d %d", &a, &b, &c); | ||
| if (a >= 0 && a < display && | ||
| b >= 0 && b < display && | ||
| c >= 0 && c < display && | ||
| a != b && a != c && b != c) { | ||
| int check; | ||
| check = checkSet (arrayCards[a], | ||
| arrayCards[b], | ||
| arrayCards[c]); | ||
| if (check) { | ||
| amountOfSets++; | ||
| printf ("\nThat's a SET! Nice job!\n\n"); | ||
| arrayCards[a] = arrayCards[available - 1]; | ||
| available--; | ||
| if (available < display) { | ||
| display--; | ||
| } | ||
| arrayCards[b] = arrayCards[available - 1]; | ||
| available--; | ||
| if (available < display) { | ||
| display--; | ||
| } | ||
| arrayCards[c] = arrayCards[available - 1]; | ||
| available--; | ||
| if (available < display) { | ||
| display--; | ||
| } | ||
| } | ||
| else { | ||
| printf ("\nThat's not a SET. Try again!\n\n"); | ||
| } | ||
| } | ||
| else { | ||
| printf("\nThat is invalid. Try again!\n\n"); | ||
| } | ||
| if (available - display == 0) { | ||
| printf ("Do you want to stop the game? Y/N?\n"); | ||
| char x; | ||
| scanf (" %c", &x); | ||
| if (x == 'Y' || x == 'y') { | ||
| printf ("You found %d SETs! Congratulations! Thanks for playing!\n", amountOfSets); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
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,5 @@ | ||
| Yael Kelmer. | ||
|
|
||
| For my final project, I want to implement a game of the card game, SET. I will make it a little simpler due to my limitations of graphic design, but it will still have the same concept as the game itself. The user will play against themselves in order to try and find as many sets possible in the cards that are dealt. | ||
| I will use functions to determine whether a set that the user chooses is actually a set. I will use loops to implement those functions. I will use structures to create the cards, since they are made up of many different characteristics. I will also use UNICODE to display the cards. | ||
| I picked this project, because when I was younger I used to play this game all the time and it has remained one of my favorites. Playing the game stimulates the brain and I think that writing the code that will implement this game will do the same. | ||
Binary file not shown.
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.
How do you intend to use arrays?