diff --git a/assignmentOne/go_fish b/assignmentOne/go_fish index d35971e..e218aac 100755 Binary files a/assignmentOne/go_fish and b/assignmentOne/go_fish differ diff --git a/assignmentOne/go_fish.cpp b/assignmentOne/go_fish.cpp index b3a83bd..6236fa7 100644 --- a/assignmentOne/go_fish.cpp +++ b/assignmentOne/go_fish.cpp @@ -32,9 +32,7 @@ Dependencies: ??? #include #include #include -#include -#include -#include +#include #include using namespace std; @@ -42,12 +40,112 @@ using namespace std; // function prototypes // class definitions +class Card +{ + // + public: + Card(char value, char suit) + { + // store the value and suit. (possible values 2-9, T, J, Q, K, A) + cardValue = value; + cardSuit = suit; + // special 1/Ace card here + if(cardValue == 'A') + { + cardNumericalValue = 1; + } + // get the numerical value of the card, casting from string to num where possible. (2-9) + if((cardValue >= 2) || (cardValue <= 9)) + { + // cast the character to number. + cardNumericalValue = (int)cardValue - 48; // numerical values 2-9 only + } + // face values here. + if(cardValue == 'T') + { + // 'ten' card + cardNumericalValue = 10; + } + if(cardValue == 'J') + { + // jack + cardNumericalValue = 11; + } + if(cardValue == 'Q') + { + // queen + cardNumericalValue = 12; + } + if(cardValue == 'K') + { + // king + cardNumericalValue = 13; + } + } + private: + char cardValue; + char cardSuit; + int cardNumericalValue; +}; // main program int main(int argc, char **argv) { + // create array of cards called deck. + vector deck; + // have two hands for cards + vector humanHand; + vector computerHand; + // game setup + // create deck by loop for 1 - 13 with each suit {(H)earts, S(pades), C(lubs), D(iamonds)}. + // use double for loop, outer for suits, inner for values. + // shuffle deck randomly? (use shuffle function from vector library) + // deal hands by taking each card from the deck, one by one (7x) (for loop here.) + // main gameplay loop (while?) + // ask for card rank/number/value + // if card is in hand, // return 0 return 0; } -// compiles using "g++ -Wall -pedantic go_fish.cpp -o go_fish" - note to programmer \ No newline at end of file +// compiles using "g++ -Wall -pedantic go_fish.cpp -o go_fish" - note to programmer + +/* +Function Name: humanTurn +Process: ??? +Function Input/Parameters: ??? +Function Output/Parameters: ??? +Function Output/Returned: ??? +Device Input/Device: ??? +Device Output/Monitor: ??? +Dependencies: ??? +*/ +void humanTurn() +{ + /* + Handles the human’s turn. It will prompt the player to ask for a card rank/number and + check if the computer has the requested rank/number. If the card is available in the + computer’s hand, it will transfer the card to the human’s hand otherwise, it will draw a + card. The function should return the number of sets collected during the turn + */ + // void function, no return. +} + +/* +Function Name: computerTurn +Process: ??? +Function Input/Parameters: ??? +Function Output/Parameters: ??? +Function Output/Returned: ??? +Device Input/Device: ??? +Device Output/Monitor: ??? +Dependencies: ??? +*/ +void computerTurn() +{ + /* + Handles the computer’s turn and it should do the same actions as the human but for the + computer. The function should return the number of set that is collected during its turn. + */ + // void function, no return. +} \ No newline at end of file diff --git a/assignmentOne/maze b/assignmentOne/maze index 0514a43..4361153 100755 Binary files a/assignmentOne/maze and b/assignmentOne/maze differ diff --git a/assignmentOne/maze.cpp b/assignmentOne/maze.cpp index f0ffc86..9113248 100644 --- a/assignmentOne/maze.cpp +++ b/assignmentOne/maze.cpp @@ -23,10 +23,6 @@ Dependencies: ??? #include #include #include -#include -#include -#include -#include using namespace std; @@ -37,6 +33,198 @@ using namespace std; // main program int main(int argc, char **argv) { + /* + Maze Layout: + Y Y Y + ============= + | S | | | X + | B | | B | X + | E | | | X + ============= + */ + + bool mazeStop = true; + bool wrongWayFlag = false; + int currentX = 0; + int currentY = 0; + int currentIteration = 0; +// int endX = 0; +// int endY = 2; +// int blockerOneX = 0; +// int blockerOneY = 1; +// int blockerTwoX = 2; +// int blockerTwoY = 1; + char directionCharacter; + + // welcome user to the maze game, explain rules, etc. + cout << "Welcome to the maze game!" << endl; + cout << "Find the end of the maze by entering in directions, such as N(North), E(East), S(South), W(West)." << endl; + cout << "Start game!" << endl; + cout << endl; + while (mazeStop) + { + // if at the starting position, display starting message. + if(currentX == 0 && currentY == 0) + { + // display starting message. + cout << "You are at the start of the maze. The only opening is east." << endl; + if(directionCharacter == 'e') + { + // + currentX = 0; + currentY = 1; + wrongWayFlag = false; + } + else + { + wrongWayFlag = true; + } + } + if(currentX == 0 && currentY == 1) + { + // + cout << "You have continued through the maze. There are openings to the east, west, and south." << endl; + if(directionCharacter == 'e') + { + // + currentX = 0; + currentY = 0; + wrongWayFlag = false; + } + if(directionCharacter == 'w') + { + // + currentX = 0; + currentY = 2; + wrongWayFlag = false; + } + if(directionCharacter == 's') + { + // + currentX = 1; + currentY = 1; + wrongWayFlag = false; + } + else + { + wrongWayFlag = true; + } + } + if(currentX == 0 && currentY == 2) + { + // + cout << "You are continuing through the maze, however, the only opening is to the west." << endl; + if(directionCharacter == 'w') + { + // + currentX = 0; + currentY = 1; + wrongWayFlag = false; + } + else + { + wrongWayFlag = true; + } + } + if(currentX == 1 && currentY == 1) + { + // + cout << "Continuing through the maze, the available directions are north and south." << endl; + if(directionCharacter == 'n') + { + // + currentX = 0; + currentY = 1; + wrongWayFlag = false; + } + if(directionCharacter == 's') + { + // + currentX = 2; + currentY = 1; + wrongWayFlag = false; + } + else + { + wrongWayFlag = true; + } + } + if(currentX == 2 && currentY == 0) + { + // + cout << "You have found the end! Congratulations!" << endl; + cout << "Press X to exit." << endl; + if(directionCharacter == 'x') + { + // set the ending flag to false. + mazeStop = false; + } + } + if(currentX == 2 && currentY == 1) + { + // + cout << "Wandering along, the new directions open are north, east, and west." << endl; + if(directionCharacter == 'n') + { + // + currentX = 1; + currentY = 1; + wrongWayFlag = false; + } + if(directionCharacter == 'e') + { + // + currentX = 2; + currentY = 2; + wrongWayFlag = false; + } + if(directionCharacter == 'w') + { + // + currentX = 2; + currentY = 0; + wrongWayFlag = false; + } + else + { + wrongWayFlag = true; + } + } + if(currentX == 2 && currentY == 2) + { + // + cout << "While continuing through the maze, you see the only opening is the west." << endl; + if(directionCharacter == 'w') + { + // + currentX = 2; + currentY = 1; + wrongWayFlag = false; + } + else + { + wrongWayFlag = true; + } + } + else + { + if(currentIteration != 0 && wrongWayFlag) + { + // print direction out of bounds. + cout << "You cannot move that way. Try again." << endl; + } + + } + // ask user for a direction, check if in bounds + cout << "Which direction would you like to go in?" << endl; + cout << ">"; + cin.ignore(); + directionCharacter = getchar(); + currentIteration = currentIteration + 1; + // if in bounds, move. (if not in bounds, warn them and start over.) + } + cout << "Thanks for playing!" << endl; + // return 0 return 0; } diff --git a/assignmentOne/wordcounter b/assignmentOne/wordcounter index adf7540..5479cf9 100755 Binary files a/assignmentOne/wordcounter and b/assignmentOne/wordcounter differ diff --git a/assignmentOne/wordcounter.cpp b/assignmentOne/wordcounter.cpp index 424772b..5ec06b3 100644 --- a/assignmentOne/wordcounter.cpp +++ b/assignmentOne/wordcounter.cpp @@ -29,6 +29,7 @@ int main(int argc, char **argv) { int numSentences = 0; int numSpaces = 0; + int wordTotal = 0; string tempString; // ask user for number of sentences cout << "How many sentences would you like to enter?" << '\n'; @@ -55,11 +56,15 @@ int main(int argc, char **argv) } // add an extra 'word' because of the end. numSpaces = numSpaces + 1; + // total the number of words. + wordTotal = wordTotal + numSpaces; // print out to the user cout << "Sentence " << sentenceIterator + 1 << " has " << numSpaces << " words." << endl; // reset word counter numSpaces = 0; + cout << endl; } + cout << "Total word count: " << wordTotal << endl; // return 0 return 0; }