University *** Semester JAVA Object Oriented Programming Solution

Verified

Added on  2023/04/23

|9
|1482
|141
Homework Assignment
AI Summary
This document provides a comprehensive solution to a JAVA Object Oriented Programming assignment, focusing on the implementation of the Observer Pattern and its application within a Blackjack game context. The solution includes modifications to a UML class diagram to incorporate the Observer Pattern, a UML sequence diagram illustrating interactions between a Dealer and Players (both aggressive and standard), and a detailed explanation of the Blackjack game's logic and implementation in JAVA. Key aspects covered include player actions (hit, stand, double down, surrender), card dealing mechanisms, and the determination of a winner. The document further presents an updated class diagram reflecting the implemented functionalities and class relationships, including Longview, Profile, Player and Blackjack game. It is a complete resource for understanding and implementing object-oriented principles in JAVA within the context of a practical game application. Desklib provides a platform for students to access this and other solved assignments, along with study tools.
Document Page
University *****
Semester
Object Oriented Programming with JAVA
Student Name:
Student ID:
Submission Date:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Table of Contents
Task 1................................................................................................................................................1
Task 2................................................................................................................................................2
Task 3................................................................................................................................................3
Task 4................................................................................................................................................4
References.........................................................................................................................................6
Document Page
Task 1
In this task, the UML class diagram will be modified to incorporate and adapt the
Observer Pattern, and implement the relationship needs to allow it to work. The UML Class
diagram is represented in the below diagram ("An Instrument Is Only As Good As Its Player"
2012).
The previously used Observer Patterns’ classes are, card(), Hand(), Deck(), Dealer(), player(),
table(), standard player(), and Trend player().
The required properties and methods for the Observe Pattern are- gameview (), playerview(),
strategy (), profile(), Loginview (), profile(), and basepalyer(), which can be added on the
extra class and methods on the observer patterns.
1
Document Page
Task 2
In this task, the UML sequence diagram is created with a Dealer, two Players, (one
who cares about
observing the cards inserted in the Hands [Aggressive Player], and one who
doesn’t [Standard Player]), a Hand for the Dealer and each Player, and any other
required lifelines. The UML sequence diagram is represented as shown below ("Early
Aggressive Treatment May Benefit African American Patients With Scleroderma" 2012).
Observer pattern method is,
The exchanges that reflect the use of Observe Pattern includes, the sequence diagram
can create interaction with the dealer and players. Further, the player can get the card in the
hand for playing the Blackjack game, where extra card can be added to the player’s hand. The
dealer can maintain the deal card and provide the card to the player.
The sequence diagram is represented below.
2
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Task 3
The Blackjack game can be created and implemented using Java. The object of the
Blackjack game starts with the player rules, where the player is asked if he/she wants
to hit, stand, double down, or surrender. If the player contains a pair, the players
might also split.
If they select hit, add another card in the same pattern as the figure shown in the task
2. If they've "busted" by going over 21, immediately collect their money and move on
to the next player. Leave their cards on the table until all the players are finished. If
they didn't bust, they may choose again.
After taking a hit, a player may no longer split or double down. They may only hit or
stand.
If a player stands, move on to the next player.
If a player doubles down, they only receive one more card and then MUST stand.
They must also double their bet by placing a second bet behind their original bet.
The Blackjack game is played with one to eight players and consistent of 52 cards
without any jokers.
The payer can be the player of the game on particular time duration to win the Ace
card, whose value is 21. The blackjack game assumes each number of card value as
10 (Henderson-Sellers and Unhelkar 2000).
First, the game is started with eight places for players and one dealer can provide the
card to the player.
Each player can play the game and add the addition card of the Blackjack card and
assume each number of card scored, based on the cards.
Ace card value is considered as 11.
2 players and dealers of the users play the game. User goes first, and then comes the
dealer’s turn. The game lets the other player’s auto win if the hand total is less than
21. Some function also assures that no player will have a hand is less than 21.
The game compares the user’s result with the other players and the highest hand wins.
The dealers can display the winner in the player list (Holt and Perry 2010).
The dealers in the beginning of the game shuffles the cards.
The player cuts the deck by inserting cut cards into the deck.
3
Document Page
The cut shouldn’t cut too close to the end of the deck. Next, put the card to the
players.
Finally, before the player begins, it is required to discard the first card in the deck
without looking at it. This is called burn card and for some reason always discard
without being used.
Longview ()- The Longview inherences class can pass the parameters on profile()
methods.
Profile ()-The profile inherences class can pass the parameter on player () and
blackjack game() methods.
Player ()- The player inherences class can pass the parameters on basedplayer(),
blackjack game(), and profile (). It can call the methods and display the values on add
the card to the player.
Blackjack game()- The blackjack game() of the inherences class can pass the
parameters and call the methods class on player(), dealer(), card(), dect(), profile() and
display the winner list of the player.
4
Document Page
Task 4
a)
The updated diagram is represented in the below diagram.
b)
In the game, the Blackjack of the class diagram can find 8 players and one dealer. The
Blackjack game can be considered as the program of main string, where the Blackjack
game manager manages Longview ().
The player first starts the game with the user profile and enters the user details (NAIR
2017).
The player() of the inherence can be used for the classes on hit(), stand(), and
doubledown ().
The inherence of the profile() can be used for the classes on getuser(), write profile ()
and load profile().
5
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
The profile inheritance can store the details of the players. The player’s view() of the
inherence creates Jlabel frame. The blackjack game contains the inherence on the
deck(), dealer(), player(), hit(), and dealcard(). The backjack game of the player()
action can find the cards passing the parameters on the class hit(), currenthand(),
stand(), doubledown(), start(), stop() and timeduration() (Pandey 2012). The player of
the hand() class is used for adding the card to addcard(), which can pass the
parameters on the class on hand() winning list.
The dect() parameters can be used for scuffling the card and to play the Blackjack
game.
Finally, the game is completed when the dealer does not wish to continue the game
after completing it. A new game may begin with a new dealer.
6
Document Page
References
"An Instrument Is Only As Good As Its Player". 2012. Nursing Standard 27 (12): 14-14.
doi:10.7748/ns.27.12.14.s21.
"Early Aggressive Treatment May Benefit African American Patients With Scleroderma".
2012. Nursing Standard 26 (41): 17-17. doi:10.7748/ns.26.41.17.s20.
Henderson-Sellers, Brian, and Bhuvan Unhelkar. 2000. OPEN Modeling With UML. Harlow,
England [u.a.]: Addison-Wesley.
Holt, Jon, and Simon Perry. 2010. Modelling Enterprise Architectures. Stevenage: IET.
NAIR, PREMCHAND S. 2017. JAVA PROGRAMMING FUNDAMENTALS. [Place of
publication not identified]: CRC Press.
Pandey, Hari Mohan. 2012. Java Programming. New Delhi: Dorling Kindersley
(India)/Pearson.
7
chevron_up_icon
1 out of 9
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]