This program creates a digital game of Hearts. It is single-player, so the actions of the other three players are handled by an algorithm.
I began this Java project by creating a Card object with three instance fields: one for the suit of the card, one for its value, and one to indicate whether or not it was played. Each instance field had a getter method to determine its value. The constructor validated the card's suit and value and then created the card using these parameters. Beyond the simple getter methods, a method was created to compare the cards using the Object superclass.
A similar approach was taken for the other two objects (Deck and Player). These three objects then interacted within a main method. However, this interaction was almost entirely numerical before the implementation of the GUI. The GUI was created using ActionListener.
Lessons Learned
This project was one of my first forays into the world of Object-Oriented Programming (OOP). OOP did not come naturally to me at first; however, through this project, I was able to internalize many of its concepts. The analogous nature of digital objects and real physical objects became much clearer. Ultimately, I realized that digital objects, just like their counterparts made of atoms and molecules, have attributes that you can discover and set. These attributes are controlled through methods. While many may find these realizations self-evident, taking on this project was necessary for me to truly comprehend them.