The last project for my Computer Science 220 class at the University of Mary Washington was one that kept me on my toes. I created a project in C++ that used two classes, one to implement a list type variable and one to implement a web page type variable, in order to make and continuously update a cache that stored information on web pages. The list type class wasn’t too bad to code. I just had to create a type that could implement a list and had methods that would add to, sort, remove from, and search through the list. The web page type class was a little more difficult to create only because it took me a while to figure out which methods to write for it. I also had to decide which methods to use operator overriding for, which was definitely a learning experience. However, my main problem was figuring out how to combine two different classes into one main program, my cache. I believe the only thing that helped me not get too confused during this part was the fact that I actually knew what a cache was at the beginning of the project so I at least knew what the main program needed to accomplish and what it needed to do in order to accomplish its goal.
While completing this project I took it one piece at a time. The first element I worked on was completing the list type class I coded. I had to create both a header and an implementation file for the list type class. Once I finished that part I worked on the web page type class. I also had to create both a header and an implementation file for this class. The hardest parts of using classes in programs is having to make sure everything matches in each file and not being able to test anything until you create all of the necessary files for the program. However, once I finished both of my classes I worked on the makefile I needed to compile all of my files together so I can run them in jGRASP. I then moved on to coding the main program. This file was tricky because I first worked on the menu of options for my cache and then moved on to coding each menu option. Once I started each menu option I had to figure out which method to call from which class using which variable. This part got kind of confusing but I figured it out one step at a time. This project taught me to break up projects into parts because if I try to just think about everything all at once I will end up getting confused and having trouble figuring out how to actually code the program correctly.
The code for this project is available at: Project 4 E-portfolio Code
For Computer Science 220 at the University of Mary Washington, I created a project in C++ that validates credit card numbers based off of three mechanisms. The first mechanism to validate the credit card number is checking the length of the number. This process took in the name of the card and compared the length of the number to the correct length for that card. If the credit card did not pass this stage it did not continue on to the final two mechanisms. It instead would print to the screen “invalid – length”. The next mechanism to validate the credit card number is checking the prefix of the number. This process took in the name of the card and compared the first, according to Visa, or first and second, according to American Express and MasterCard, numbers to the correct prefixes for that card. If the credit card did not pass this stage it did not continue on to the final mechanism. It instead would print to the screen “invalid – prefix”. The final mechanism to validate the credit card number is Luhn’s algorithm. For Luhn’s algorithm the number needs to be reversed, every other number starting with the second number gets doubled, each individual digit is added together, and if the integer that results is a multiple of ten then the number is valid. If the credit card did not pass this stage the card number was not valid. It would print to the screen “invalid – luhns”. If the credit card number passed all three of the mechanisms it was a valid card and “valid” would be printed to the screen.
This project was definitely the hardest project I have worked on for multiple reasons. First, this project took me about two-three weeks to complete while working on different pieces every day. I usually spend about two-three days on a project and am done. I am glad this program took a longer time to work through and complete because it is more like real, job-related projects that I will eventually face in my career. Second, this program relied heavily on functions which I haven’t used in about two years. The re-introduction to functions wasn’t too bad however, applying what I was taught in a language that I have never used was rather difficult. Third, many times I would try something and it wouldn’t work correctly. For example, in Luhn’s algorithm I had to write code to reverse a string of numbers. I had designed a loop to reverse the string manually that seemed like it should have worked. However, each time I ran the program the string would reverse correctly but not be usable in the next steps of Luhn’s algorithm. When I took my source code to my professor she thought it would work too but instead of helping me try to fix it just googled a solution that worked completely fine. I never even thought about googling my problems because I typically like to fix them myself but I learned that sometimes I just need to google something because the solution to it is beyond my knowledge, temporarily.
While completing this project I took it one piece at a time. The first element I worked on was completing the part in main that controlled input and output. Once I finished that element I moved onto writing the function that checked the length of the card number. I added the call to this function into main so I could test it. Once I finished that element I moved onto writing the function that checked the prefix of the card number. I added the call to this function into main so I could test it. Once I finished that element I moved onto writing the function that checked for Luhn’s algorithm. This function gave me the most problems but once I finished it the project moved a lot quicker. I added the call to this function into main so I could test it. Once I finished that element I worked on fixing main so it would stop applying checks once one of the checks found the card to be invalid. The only thing left after that was making main read input from a file so I wouldn’t have to type in the card names and numbers repetitively. I then verified that the program was running correctly by testing the output with an input file I made to ensure the program returned the correct output that I was expecting.
The code for this project is available at: Project 2 E-portfolio Code