Page 1 of 1

Part 1 Carefully read the question statement and Greek Geek's message. Using UML diagrams to help you (optional - don't

Posted: Mon May 02, 2022 12:40 pm
by answerhappygod
Part 1
Carefully read the question statement and Greek Geek's message.
Using UML diagrams to help you (optional - don't submit them if you
use them), complete the following tasks:
1. Create a class named Game. It should contain the
following:
Six fields, including the 4 specified by Greek Geek (title,
product code, price and genre), and min price and max price (price
range).
HINT: for the Genre field, create an
empty Enum you will fill with info later on.
A constructor that initialises all the fields except for the min
and max price.
Getters for all the fields.
Setters for the min and max price fields.
A method that describes the game, e.g., the format should be as
follows:
Pac-Man (25505)
> Genre: maze action > Price: $45.00
Now fill out the Genre Enum with the info provided by
the Greek Geek. It should contain all 5 genres, and an appropriate
toString method.
Create a simple class named Geek. It should contain the
following:
Two fields, as specified by Greek Geek.
A constructor that initialises both fields
Getters for each field.
4. Create a class named AllGames. It should contain the
following:
A field that stores a collection of Game objects.
A method to add a Game to the field.
A method called findGames that has a Game
parameter, and searches the
collection of Games for Games that match the
parameter, returning a collection of matching Games.
HINT: compare the genre and check the price
range.
5. Create a class named FindAGame. It should contain
the following:
A method to load the game data from the allGames.txt
file. It should have a String file path parameter, and
return an instance of the AllGames class. HINT
1: In a loop, parse the info in the file, and use it
to
create Game objects, which you can add to the collection
field of
an AllGames object via its addGame
method.
HINT 2: For Part 1, it is safe to ignore the
platform, perspective and multiplayer data in the file.
A method (maybe name it submitOrder) to write the
Geek user's order to a txt file. The method should have a
Geek and Game parameters. The name of the file
should be the geek's name, followed by the game produce code, with
no whitespaces, e.g.;
Walter_Shepman_25505. The file should contain relevant
details in the following format:
Order details:
Name: Walter Shepman Phone number: 0486756465 Game: Pac-Man
(25505)
2. A main method, which:
0. Requests user input for genre and price range, using this
data to initialise a Game object
HINT 1: set unknown parameters to null
or 0).
HINT 2: Remember to use the setters to set the
min and
max price fields
This object should be used to search for a real game (in
allGames) that matches the user's preferences.
The user should be presented with any matching games in the form
of a drop-down list, allowing them to select a game (or
NA).
HINT 1: keep track of the mapping between the
Game title shown in the dropdown list, and the
Game itself by using a Map.
HINT 2: populate the dropdown list using the
Map keyset
The program should account for 3 situations 1) matching
games
are found and user selects one 2) matching games are found
and
user selects none 3) no matching games are found.
If the user selects a matching game, the user's info should
be
requested and used to create a Geek object, which
should then be passed (along with the chosen game) into the
submitOrder method.
To achieve full marks in this section, please ensure appropriate
exception handling and full documentation of your solution.
To test if your program is fully functional, run it, and
select/enter the following:
Action and Adventure 50
90
You should get the following output: