As part of my assignment this week (computer programming I), I am supposed to work on the UNO game that we are working on throughout the class. The game will be played between ONLY computers, so no keyboard input except for the occasional enter to make the game continue (kinda boring right?). This week we are supposed to make some classes for each part of the game (such as the CARD class and the HAND class). I was able to do this, but the second part of my assignment--to have 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."-- has me stuck. I've tried multiple printing methods that I know with my incredibly limited skills, but I've come up with nothing. Any Ideas?
Here's the Code:
public class CARD
{
public String color;
public int value;
private Random random;
private String face;
public CARD(int v, String c)
{
value = v;
color = c;
}
public CARD()
{
random = new Random();
value = random.nextInt(28); // 108 cards in a deck and it Can be reduced to 27 which ignores colors
// Assigns value
if (value >= 14) // Some cards show up more often (numbers)
value -= 14;
// Assigns color
random = new Random();
switch(random.nextInt(4) ) //learned about switches here: https://www.youtube.com/watch?v=RVRPmeccFT0
{
case 0: color = "Red";
break;
case 1: color = "Green";
break;
case 2: color = "Blue";
break;
case 3: color = "Yellow";
break;
}
// If the card is wild
if (value >= 13)
color = "none";
}
}