C++ Projects

Soccer Point Tracker

This program keeps track of individual soccer players' points throughout the match. I decided to practice using a Struct data structure for this.


Method:

I first create a struct, named Futbolero, to hold the variables that will hold the player's name and stats. Then I create a static integer variable to hold the size of the team, and instantiated 'Futbolero' with an object array called 'player' with the size of the variable we just created. I then initialize variables that hold the total team points and points scored by the highest scorer.
Next I iterate through the 'player' array, asking the user for input to fill in the desired fields for each player (name, points, and number) for every player on the team. I access the attributes of the Futbolero struct by way of the 'player' object. Once all the fields are inputted, the program tallies the team's total points, as well as the highest score.


Spellchecker using Levenstein Distance

This was a very challenging program I made as an end-of-year project to demonstrate Object-Oriented Programming concepts. In particular, this program is used to check the spelling of words and if a word is deemed to be misspelled, suggests corrections based on the Levenshtein distance, which measures the similarity between words and measures how many edits would be needed to transform one word into another using three operations: Insertion, Deletion and Substitution. I used a file called words.txt to serve as my dictionary in order to compare the user-inputted words (in spellCheckMain.cpp) for correct spelling.


Method:

I first defined a class in spellCheck.h with functions that would allow me to load the dictionary file, find words, and give suggestions for corrections. Then in spellCheck.cpp I implement the member functions that were defined in spellCheck.h, and also the function to implement the Levenshtein distance. This Levenshtein distance function takes the reference address of two strings as parameters, and use size_t for array and loop counting. I then loop through the strings to find the 'distance' between the words (aka number of transformations needed to change one of the given words to the other). Next I use the 'suggest' function, which takes a string and an integer as arguments, to check the given string for correctness and display the integer amount of words as possible suggestions for the word which incorrectly spelled. This method takes into account the Levenshtein distance used in the previous function, and suggests us the words based on the minimum number of transformations needed to get to the correct words. For instance, calling suggest("buble", 3) will return three suggestions: bible, bugle, and bubble.