Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This programming assignment revolves around embellishing the design and implementation of Lab 3. Our requirement for Lab 3 drove us to implement a Class called

This programming assignment revolves around embellishing the design and implementation of Lab 3. Our requirement for Lab 3 drove us to implement a Class called SweetMillion that represented the popular NYS lotto game of the same name. Your solution leveraged the services of another Class Randomizer and was hopefully as modular as possible, but the solution was intended to be fairly fixed that is, it modeled the rules of that game only.

Imagine that NYS was very thrilled with your SweetMillion implementation, and offered you a chance to build a Quick Picker Solution for all games present and future. How would you go about re-factoring your SweetMillion solution into one that covered our new requirements?

One possible approach might look like this.

That is, you might have an abstract base Class of sorts that allows you to share common data and methods with game specific sub-classes.

This is a reasonable approach, but can it be better - more flexible and easier to maintain?

First, what ongoing changes would you be responsible for?

New game implementations.

Rule modifications to existing games.

NOTE: all games forces our implementations to include 2 pools of numbers rather than just one as many NYS lotto games pick N numbers from a primary pool and N supplementary numbers.

What if we could build a single Class solution that would support ALL games present and future? - one that made use of configuration files (property files). What would that solution look like?

The model above could rely on a collection of Java properties files. Each properties file would dictate the rules of one Lotto Game.

A properties file with the following format has all information required to cover all game behavior details.

Example 1

###################################################

## Pick10 game definition - pick 10 in 80 numbers

GameName=Pick 10!

Pool1=10/80

Pool2=0/0

Vendor=CSC330 Corner Store

Example 2

###################################################

## Mega Million game definition - pick 5 in 75 and then 1 in 15

GameName=MegaMillions!

Pool1=5/75

Pool2=1/15

Vendor=CSC330 Corner Store

Your assignment:

Implement a solution that would NOT require us to modify any Java code in order to support an evolving Lotto Game set. One that supports the design suggested above where:

A new game would require you to add a new .properties file to your deployment.

Updated rules to an existing game (or a Name Change) would require you to modify an existing .properties file.

And thus, unless something very fundamental changes about the way NYS Lotto works, you would never need to modify, recompile and re-test your code base.

This can clearly be called a Configurable solution!

Create a custom Exception called QuickPickerException that will be throw by your QuickPicker Class if one of the conditions occur.

The specified game does not exist (missing .properties file)

A required property is missing from the .properties file.

You need to implement the following Classes:

QuickPicker implements the behavior of a generic QuickPicker solution that depends on the details found in a game specific .properties file everything needed to provide the same functionality that your SweetMillion solution provided.

QuickPickerException needs to extend the Exception Class. Use the edu.cuny.csi.csc330.newradio.RadioException Class as a solid point of reference / template.

NOTE:

Your QuickPicker Class will require 1 argument and accept an optional second argument:

The name of the Game to be played. Name must match the name of the properties file e.g., a file called MegaMillions.properties must exist to support a 1st argument of MegaMillions

The number of bets/games to be generated. Like your SweetMillion solution, the default number of games should be one.

Your .properties files should live under the src folder/directory of your Eclipse project folder.

You will be utilizing the java.util.PropertyResourceBundle Class to gather game properties details. Refer the edu.cuny.csi.csc330.examples.PropertyBundleDemo Class in our source tree.

You will be submitting 4 or more files:

QuickPicker.java

QuickPickerException.java

One or more .properties files that drive the rules of one or more Game of your choice (actual NYS Lotto game, or one you make up)

: if you only submit one, you must provide and test a game that uses the second / supplementary pool of numbers.

This Word Doc with the output section below filled in. Again, make sure you show a sunny day successful output as well as a failed attempt that throws a QuickPickerException as shown below.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago