- Joined
- Oct 13, 2004
I am really struggling with these projects that are to do with creating objects and methods...
Design and implement a class called Card that represents a standard playing card. Each card has a suit and a face value. Create a program that deals 20 random cards.
Now i think im starting to get lost here...I have attempted below...but i think im doing this the wrong way...
Is there a better way to do this? Can somebody steeeeeeer me in the right direction?
(its not complete, but you can see where im heading...i think its wrong)
Design and implement a class called Card that represents a standard playing card. Each card has a suit and a face value. Create a program that deals 20 random cards.
Now i think im starting to get lost here...I have attempted below...but i think im doing this the wrong way...
Is there a better way to do this? Can somebody steeeeeeer me in the right direction?
(its not complete, but you can see where im heading...i think its wrong)
Code:
import cs1.Keyboard;
import java.util.Random;
import java.lang.Math;
// card class which creates the card objects. It creates the suits(Hearts
// Diamonds, Clubs and Spades and
// the face values. 1-13
class Card
{
private int cardNumber;
private int cardNumberValue;
private String cardSuitValue;
private String cardFace;
// creates the card objects
public static void main(String[] args)
{
card = new card();
}
//Creates the cardNumber's and returns it.
public int getNum()
{
cardNum = Math.Random(1) +13;
return cardNum;
}
//assigns each cards number to a string with the proper name
public String getNumValue()
{
if (cardNum == 11)
cardNum == "Jack";
if (cardNum == 12)
cardNum == "Queen";
if (cardNum == 13)
cardNum == "King";
cardNum == cardNumber;
return cardNumber;
}
}
public class P4_6
{
public static void main (String[] args) extends Card
{
System.out.println("You got: " +card.getNumber);
}
}