Due: before class next Monday, November 7
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:
roulette.tar
into Eclipse using Import --> Existing Projects Into Workspace and
then "Select archive file"Execute the code. What is the main driver for this project?
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)?Note: There is one bug in the code: determining if Odd/Even Bet was won is incorrect.
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
class (i.e., are constant across the
hierarchy), and which completely in the Bet
child classes (i.e., must be specialized across the hierarchy)?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:
Using Eclipse, make a jar file from your project, which should
include your source code, in a file called assign9.jar
Save the file in your cs209 directory.
See Assignment 6 if you need
reminders about how to copy your file to the CS department
servers.
Submit your file using submitJar.sh assign8
Your grade will be based on