Due: Before class Wednesday, November 13
Objective: This assignment is intended to get you to practice some of the programming and design techniques discussed in class recently and consists of the following activities:
There are many different ways to bet on the results of spinning a roulette wheel. The current program only supports three such ways; however, the next version of the program should support three additional ways to bet on the results. Analyze the design of the current program from the perspective of how open it is to adding new kinds of bets and how closed it is to modification.
To help direct your analysis, consider the following questions:
Bet
class?Game
to allow
the user to make another kind of bet that paid one to one odds and
was based on whether the number spun was high (between 19 and 36)
or low (between 1 and 18)?Examine the code given and refactor it according to the Open-Closed Principle as well as the other design principles we have studied: You may create any new classes you want to solve this problem.
To help direct your refactoring, consider the following questions:
Bet
super-class (i.e., are constant across the
hierarchy), and which completely in the Bet
sub-classes (i.e., must be specialized across the hierarchy)?Game
class create the
correct Bet
sub-class?You are most focused on extensibility but also look for other code smells in your code.
You should provide a set of tests that verify your modified program still works as intended. Tests can be in the form of input data files, driver programs, or other classes that verify every line of code written works as intended. Use the best/most appropriate form of testing for the specific code under test.
To help direct your testing, consider the following questions:
Using your improved code, add the three bets given in the original specification not implemented in the code given to you, adding as little new code as possible.
In a text file, briefly compare the effort to create a new bet in your improved code to how you would have done it in the original code. To focus your answer, consider the following questions:
Create a tar file from your project and copy it into
an assign10
directory.
Your grade will be based on