I want to double the score if the cards have the same suit or value and if two cards have the same both suit and value, the score get tripled. And the 2 of clubs is a 20 points. i already wrote the basics of the program which it adds two random cards together and whoever get the higher score win. But i don't know how to compare arrays of two variable. Here is the original one that i already had written:

class Card{
GetCards gc = new GetCards();
public static void main(String []args){
new Card();
}
public Card(){
int c1, c2, c3, c4=0;
System.out.println("COMPUTER CARDS: ");
c1 = getCardValue();
c2 = getCardValue();
System.out.println("Computer score: "+(c1+c2));
System.out.println("YOUR CARDS: ");
c3 = getCardValue();
c4 = getCardValue();
System.out.println("Your Score: "+(c3+c4));
if ( (c1+c2)>(c3+c4))
System.out.println("You Lose");
else if ( (c1+c2)<(c3+c4))
System.out.println("YOu win");
else System.out.println(" Draw");
}
public int getCardValue(){
String card = gc.finalCard();
System.out.println(card+": ");
int value = gc.i;
if(value>9)value=10;
else if(value==0)value=11;
else value++;
return value;
}
}
class GetCards{
int i,j;
String card;
GetCards(){}
public String finalCard(){
String []suit = {"Hearts", "Clubs", "Diamonds", "Spades"};
String []value = {"Ace","1","2","3","4","5","6","7","8","…
i= (int) (Math.random()*value.length);
card=value[i];
j= (int) (Math.random()*suit.length);
card=card+"of "+suit[j];
return card;

}
}

my hw is due tmr so please help me.

class Card{
    int i, j;
    int counter=0;
    String [] cards= new String[4];
    int [] val = new int[4];
    public static void main(String []args){
    new Card();
}
public Card(){
    int c1, c2, c3, c4=0;
    int compScore=0;
    int urScore =0;

    System.out.println("COMPUTER CARDS: ");
    c1 = getCardValue();
    c2 = getCardValue();
    System.out.println("YOUR CARDS: ");
    c3 = getCardValue();
    c4 = getCardValue();
    compScore = c1+c2;
    urScore = c3+c4;
    if(cards[0].equals(cards[1]) && (val[0]==val[1]))
        compScore *=3;
    else if(cards[0].equals(cards[1]) || (val[0]==val[1]))
        compScore *=2;

    if(cards[2].equals(cards[3]) && (val[2]==val[3]))
        urScore *=3;
    else if(cards[2].equals(cards[3]) || (val[2]==val[3]))
        urScore  *=2;

    System.out.println("Computer score: "+compScore);
    System.out.println("Your Score: "+urScore);
    if ( compScore>urScore)
        System.out.println("You Lose");
    else if ( compScore<urScore)
        System.out.println("YOu win");
    else System.out.println(" Draw");
}
public String[] finalCard(){
    String card="";
    String []suit = {"Hearts", "Clubs", "Diamonds", "Spades"};
    String []value = {"Ace","1","2","3","4","5","6","7","8","9","10"};
    i= (int) (Math.random()*value.length);
    card=value[i];
    j= (int) (Math.random()*suit.length);
    String [] ret = {card, suit[j]};
    return ret;
    }   
public int getCardValue(){
    String [] card = finalCard();
    System.out.println(card[0]+" of "+card[1]+": ");
    cards[counter]=card[1];
    val[counter] = i;
    counter++;
    int value = i;
    if(value>9)value=10;
    else if(value==0)value=11;
    else value++;
    return value;
}
}

I am not a regular visitor so mail me in case of any help at
<snipped>

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.