User Tools

Site Tools


user:afassett:free_cell
Files

main.c calls functions, user interface made here as well as some of nodemanip.c functions
list.h
initializes the variables and pointers (does not set the variables)

display.c prints the rows, Has the ability to print all 52 to check if they are non-repeating. cards are not implemented to print suit just #'s so far.
nodemanip.c
makes the linked list, inserts and deletes nodes. Makes the list with random number 0-51


Problems

Three problems encountered that most difficult during this project
Random Numbers
non-repeating numbers
interface
As you can see non of the problems i had were of making a list linked and having to manipulate nodes such as insert and removing them.
However still have some difficult telling the difference between stack and linked list. Stack→linked_list→node
I had difficulty making the numbers non-repeating as well as making them into rows. Instead of identifying the cards as they are I made them numbers 0-51, which only until the end when they would be printed would they be convert from numbers to cards. The difficult part of making the numbers non-repeating was checking to see if the number were used before. I tried using array and using pointers, however the pointers made this approach t confusing to remember where i was pointing. In the nodemanip.c it can be seen how this was accomplished, simple look for the comments in the source code. An array was the best approach for this checking system. Other problems encountered was making the rows, 8 rows were needed and each would have different pointer names. I haven't come up with a solution for making the rows without unique names and there problem grow when approaching the interface with the user. Seeing project that use <curse.h> would be a great approach. The problem with this interface is that the first user input the rows are one number off. Meaning that if you want row 5 you will need to input 6, and then yours inputs the number 6 to insert a card into row 6. Also what is not stated in the program but is stated in the README file. That when a user inputs the row they wish to take action, if the user inserts the number of the same row(remembering that the first action is 1 off) the card of that row will inserted in the pile for that cards suit of course that's if it passed the test to see if it's the next card needed. The pile of cards is all called stack in the program and is not complete, because a case swith could not be used a series of “if” states followed by add's and or's to test if the cards is next in list. Reasons for why a case switch can't be used are for the cards of linked list are pointers and a case switch can only test for integers. However if a case switch could be used and unlike in the main.c file where case switch functions are nested in a very ugly way i believe they would work ever well. I.G card 51 test in switch (51) and having a case 0-51: “function here” break;. Where in main.c has the problem implementing what the user wants to do.

Future Idea

Much like the command info where a user can simply hit enter to take a action would be a much better interface. Plus with colored background for the hearts and dimmaond suits would be help to the user.

Other

As is the program is in finalproject the numbers are not converted into cards this is because I have not desiced how I want them to look when they print. I have come up with for example when 51 is printed [H,K] meaning 'H' for hearts and 'K' for the king so it will always print suit first than the number. this would make the program very simple however with if states to check for the 0-51 cards it would mean a lot of extra work for a simple test. Another approach would be to have an array that would be char and test for the cell number of that array with the card. Which the cell would print out the suit and than the card number. This would remove the need for nested if states, however interfacing is would still be a mess for reading as well as just playing the game. I.G [H,K],[D,8],[H,7],[S,6] or [H,K]→[D,8]→[H,7]→[S,6]. until i figure a better way to print the cards iv left it number for easier reading and playing.

Versions
user/afassett/free_cell.txt · Last modified: 2010/11/27 23:14 by afassett