Hi pleas help with this lab Assignment with the OUTPUT in JAVA. Thanks Imagine t
ID: 3825378 • Letter: H
Question
Hi pleas help with this lab Assignment with the OUTPUT in JAVA. Thanks
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?
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)
NOTE: 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.
Sunny Day Scenario
-----------------------------------
-------- Cash 4 Life! --------
Thu Mar 31 08:58:17 EDT 2016
( 1) 03 27 32 49 56 (( 03 ))
( 2) 16 23 38 46 56 (( 04 ))
( 3) 06 22 27 41 58 (( 04 ))
( 4) 10 27 31 33 34 (( 02 ))
( 5) 11 13 17 35 43 (( 01 ))
----- (c) CSC330 Corner Store -----
-----------------------------------
Rainy Day Scenario
QuickPickerException [code=1, toString()=edu.cuny.csi.csc330.prof.lab6.QuickPickerException: Can't find: CashForLife]
Unknown Game - Can't locate specified game.
NOTE:
Place your program’s output here – for both a successful launch and one that threw an QuickPickerException:
###################################################
## Pick10 game definition - pick 10 in 80 numbers
GameName=Pick 10!
Pool1=10/80
Pool2=0/0
Vendor=CSC330 Corner Store
Explanation / Answer
Hi,
Lets state how to make a program configurable : using proerties file:.
1. create a property file say program.properties under the main project folder.
2. make variables' entry in the property file:
vname=value
[put no semicolon just press enter and next name value]
3. in your main program, load it:
File file = new File("program.properties");
FileInputStream fis = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fis);
fis.close();
4. Now access values using this properties variable:
properties.getProperty("name") // it would return value.
5. your program is now configurable.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.