Expand|Select|Wrap|Line Numbers
- 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","9","Ten","Jack","Queen","King"};
- i= (int) (Math.random()*value.length);
- card=value[i];
- j= (int) (Math.random()*suit.length);
- card=card+"of "+suit[j];
- return card;
- }
- }
i have trouble define an array of a variable, i mean i don't know how to compare two arrays of two cards. please help me thanks