librejack

Blackjack clone written in java
git clone https://github.com/michaelneuper/librejack.git
README | Files | Log | Refs | LICENSE

commit 29eb28e89afc5c19474c4766fe3d3290f993a4a3
parent bf602d070fc865a0d3fe73ffe06e1a8de88ac7c6
Author: Michael Neuper <73108749+michaelneuper@users.noreply.github.com>
Date:   Fri,  7 Oct 2022 21:05:24 +0200

update Person.java

Diffstat:
Msrc/model/Person.java | 51+++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/model/Person.java b/src/model/Person.java @@ -1,9 +1,56 @@ package model; +import controller.Hand; + /** * Parent class of the Player and Dealer Objects - * @author michael + * + * @author Michael */ public abstract class Person { - // TODO + + private Hand hand; + private String name; + + /** + * Creates a person + */ + public Person() { + this.hand = new Hand(); + this.name = ""; + } + + public Hand getHand() { + return hand; + } + + public void setHand(Hand hand) { + this.hand = hand; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Method to check if a person has blackjack + * + * @return true (if player has a blackjack) + * @return false (if player does not have a blackjack) + */ + public boolean hasBlackjack() { + return this.getHand().calculateValue() == 21; + } + + /** + * Prints a formatted version of the person's hand + */ + public void printHand() { + System.out.println(this.name + "'s hand:\n" + this.hand + "[" + this.hand.calculateValue() + "]"); + } + }