/**
* @(#)Card.java
*
*
* @author Evan JR
* @version 1.00 2012/11/14
*/
import java.util.Random;
public class Card
{
private int suit;
private int face;
private String suitName;
private String faceName;
public Card()
{
Random gen = new Random();
int suit = gen.nextInt(4)+1;
int face = gen.nextInt(13)+1;
}
public int getSuit()
{
return suit;
}
public int getFace()
{
return face;
}
public String faceName()
{
switch(face)
{
case 1: faceName = "Ace";
case 2: faceName = "Two";
case 3: faceName = "Three";
case 4: faceName = "Four";
case 5: faceName = "Five";
case 6: faceName = "Six";
case 7: faceName = "Seven";
case 8: faceName = "Eight";
case 9: faceName = "Nine";
case 10: faceName = "Ten";
case 11: faceName = "Jack";
case 12: faceName = "Queen";
case 13: faceName = "King";
}
return faceName;
}
public String suitName()
{
switch(suit)
{
case 1: suitName = "Diamonds";
case 2: suitName = "Clubs";
case 3: suitName = "Hearts";
case 4: suitName = "Spades";
}
return suitName;
}
public String getsuitName()
{
return suitName;
}
public String getfaceName()
{
return faceName;
}
}
Hello there. I'm a fairly novice Java programmer, and I have a lab assignment due at my University. My prof isn't available as he's gone for a few days so I'm stuck to try and solve this problem myself.
I'm having difficulties with this random generator as my driver program below is giving me bizarre values.
Card@8746d23 Card@13a9192b Card@42b36022 Card@e6c7a64 Card@73d742a1 Process completed.
Any help you can give me is greatly appreciated, I understand you cannot just simply give me all the answers. I need to figure this myself, but I'm stumped

New Topic/Question
Reply



MultiQuote





|