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.