Classes about Classes

This past week the focus has turned to working with classes. The process was a tricky one since this is where my previous coding experience is reaching its limit, and the task required me to do things that have not been necessary for me before. Most of my working time has been spent on the task of creating a class able to simulate a deck of cards.

To do this I created a Card class meant to simulate cards by their value and color. I then added a function intended to create the cards and assign them as ”X of [Color]” (i.e. 3 of Hearts), and from this created another function writing out an entire deck just to see if things worked as intended.

From there I created a new class, Hand, which task was to work as a player’s hand in a card game, able to draw and contain cards from the Card class to a maximum of five cards. The Hand would also be able to discard cards and draw new ones to fill the emptied spots.

From there I ended up stuck with trying to get the two classes to work together as I intended them to do. Several smaller issues appeared in the process and a lot of time has gone into trying to think out solutions for them. At this point the progress slowed down considerably and has for now left me in a temporal stalemate. I do however expect to be able to solve this if I just take the time to think over alternatives.

Hopefully I will be able to fix the issues over the weekend and return next week with a working system. I have an idea on how to rewrite the code so that it does what I want, which will hopefully work. We will see how it went next week!

/Stefan

p.s. The lack of included code is due to having recently encountered some new issues which will likely require me to rewrite a fair bit of the code. I apologize for this inconvenience,

About Stefan Ekdahl

2014  Programming