Converting procedural design to object oriented design - Blackjack
CPE 103 lab
Compile and execute this source code
for a Blackjack game.
Examine the source code and notice that it is mostly a procedural
oriented design. There is one big class that does most of the
work. As the one gesture toward OO design, there is a Card
class.
The objective is to refactor the design to make it more object
oriented. Perform the refactorings below in the order listed.
(This is a new lab. To assist your intructor in improving it, please
keep track of how long it takes you to complete each listed item.)
- Create a Hand class and a Deck class by moving pieces of existing
code into separate classes.
- Take advantage of Generics and change all references to "
Vector"
to "Vector<Card>".
- Replace the
shuffle() method with a call to the
Collections framework shuffle() method.
- Rework the Card class to use enums.
- Refactor any procedural code that doesn't follow structured
programming principles (e.g. break or return inside
a control structure).
Write a one page (max) description of your refactored solution and
explain the benefits your solution offers over the original.
Be specific, using concrete details from the problem domain of card games.
Clearly it takes more effort to produce the OO solution.
Is the effort worth the benefits? Justify your answer.
Submission
Print your completed source code and a sample execution
following the class
guidelines. Attach them to the back
of your one page summary and submit them in class.