Create a UML diagram and then write the code for the object classes needed for your UNO game. You…

Create a UML diagram and then write the code for the object classes needed for your UNO game. You….

Create a UML diagram and then write the code for the object classes needed for your UNO game. You will need a minimum of 3 classes: a. A Card class (models an individual UNO card) b. A Hand class (models a player’s hand) c. A Deck class (models the entire UNO deck) You may add other classes as you see fit. Test your program by writing a console application (a driver program) that creates a deck of UNO cards, deals the cards to two or more players, and displays the contents of each player’s hand.

This is what I have so far…

package W5UML;

public class Card

{

enum Color

{

Red, Blue, Green, Yellow, Wild;

private static final Color[] colors = Color.values();

public static Color getColor(int i) {

return Color.colors[i];

}

}

enum Value

{

Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, DrawTwo, Skip, Reverse, Wild, Wild_Four;

private static final Value[] values = Value.values();

public static Value getValue(int i)

{

return Value.values[i];

}

}

private final Color color;

private final Value value;

public Card(final Color color, final Value value)

{

this.color = color;

this.value = value;

}

public Color getColor() {

return this.color;

}

public Value getValue() {

return this.value;

}

public String toString()

{

return color + “_” + value;

}

}

package W5UML;

public class Deck {

private Card[] cards; // for a deck , you need to now the cards

private int cardsInDeck;

public Deck() {

cards = new Card[108]; // how many cards are in UNO

}

public void reset()

{

Card.Color[] colors = Card.Color.values();

cardsInDeck = 0;

for(int i = 0; i < colors.length-1; i++)

{

Card.Color color = colors[i];

cards[cardsInDeck++] = new Card(color, Card.Value.getValue(0));

for(int j = 1; j < 10; j++)

{

cards[cardsInDeck++] = new Card(color, Card.Value.getValue(j));

cards[cardsInDeck++] = new Card(color, Card.Value.getValue(j));

}

Card.Value[] values = new Card.Value[]{Card.Value.DrawTwo,Card.Value.Skip,Card.Value.Reverse};

for(Card.Value value : values)

{

cards[cardsInDeck++] = new Card(color, value);

cards[cardsInDeck++] = new Card(color, value);

}

}

Card.Value[] values = new Card.Value[]{Card.Value.Wild, Card.Value.Wild_Four};

for(Card.Value value : values)

{

for(int i = 0; i < 4; i++)

{

cards[cardsInDeck++] = new Card(Card.Color.Wild, value);

}

}

}

public Card drawCard() { ///////// add this to draw cards look this up later

// TODO Auto-generated method stub

return null;

}

}

package W5UML;

import java.awt.Font;
import java.util.ArrayList;
import java.util.Arrays;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Hand {

private int currentPlayer;
private String[] playerIds;

private Deck deck;
private ArrayList<>> plyersHand; // this is all of the players hands
private ArrayList stockpile; // all played hands stored

private Card.Color validColor;
private Card.Value validValue;

boolean gameDirection;

public Game(String[] pids) {
deck = new Deck();
deck.shuffle();
stockpile = new ArrayList();

playerIds = pids;
currentPlayer = 0;
gameDirection = false;

plyersHand = new ArrayList<>>();

for (int i = 0; i < pids.length; i++) {
ArrayList hand = new ArrayList(Arrays.asList(deck.drawCard(7)));
plyersHand.add(hand);
}
}
public void start(Game game) {
Card card = deck.drawCard();
validColor = card.getColor(); // they can put down color of card
validValue = card.getValue(); // or the value to match

if (card.getValue() == Card.Value.Wild) {
start(game);
}

if (card.getValue() == Card.Value.Wild_Four || card.getValue() == Card.Value.DrawTwo) {
start(game);
}

if (card.getValue() == Card.Value.Skip) {
JLabel message = new JLabel(playerIds[currentPlayer] + “was skipped!”);
message.setFont(new Font(“Arial”, Font.BOLD, 48));
JOptionPane.showConfirmDialog(null, message); // this will print msg

if (gameDirection == false) {
currentPlayer = (currentPlayer + 1) % playerIds.length; //players order gets + 1 or – 1 skipping players
} else if (gameDirection == true) {
currentPlayer = (currentPlayer – 1) % playerIds.length;
if (currentPlayer == -1) {
currentPlayer = playerIds.length – 1;

}

}
}
if (card.getValue() == Card.Value.Reverse) {
JLabel message = new JLabel(playerIds[currentPlayer] + “The game direction changed!”);
message.setFont(new Font(“Arial”, Font.BOLD, 48));
JOptionPane.showConfirmDialog(null, message);

}

}
}
UMLuno.ucls X <<java Class>> Deck WSUML cardsInDeck: int Deck() reset():void drawCard():Card <<java Class>> Hand2 WSUML -deck

Create a UML diagram and then write the code for the object classes needed for your UNO game. You…