Apachefoorumi.net
Sielussani on mursu...
import java.util.*;
public class CardGame {
/**
* @param args
*/
public static void main(String[] args) {
Random random = new Random();
int b = 0;
int c = 0;
double d;
System.out.println("Welcome to my card game!");
System.out.println("Rules are simple: it is your versus the computer.");
System.out.println("Every round you draw a card from the deck, the higher card wins.");
System.out.println("Good luck!");
System.out.println("*********************************************************************************");
System.out.println("How many rounds would you like to play?");
Scanner onin = new Scanner(System.in);
d=onin.nextInt();
System.out.println("*********************************************************************************");
while (d > 0)
{
int a = random.nextInt(13) +2;
System.out.println("You have drawn " +a +".");
int e = random.nextInt(13) +2;
System.out.println("Your opponent has drawn" +e +".");
if (a > e)
{
System.out.println("You have won this round!");
d--;
b++;
}
else if (e > a)
{
System.out.println("Oh no! Your opponent has won this round!");
d--;
c++;
}
else if (a == e)
{
System.out.println("This round is a tie! Lame..");
d--;
}
Scanner something = new Scanner(System.in);
something.nextLine();
}
System.out.println("The game is finished!");
if (b > c)
{
System.out.println("You've won the game! Congratulations!");
}
else if (c > b)
{
System.out.println("Your opponent has won the game! You suck!");
}
else if (b == c)
{
System.out.println("The game ended in a tie! Barely saved your rep there mate..");
}
}
}
if omaveto < vastustajanveto
print("hävisit, vastustaja veti numeron" x)
elif omaveto > vastustajanveto
print ("voitit, vastustaja veti numeron" x)
elif omaveto=vastustajanveto
print (tasapeli, vastustaja veti numeron" x)
else
homma kusee
QuoteWelcome to my card game!
There is a fair, shuffles stack of cards in the middle of the table.
You and your opponent will both draw a card, and the higher of the two cards wins.
Cards are shuffled back into the deck after each round.
The player who at the end of the game won most rounds wins the game.
After you are done reading the current round, press enter to start a new round.
***********************************************************************************************************************
How many rounds would you like there to be?
3
***********************************************************************************************************************
You have drawn 12.
Your opponent has drawn a 13. You lose this round!
You have drawn 11.
You have drawn 12.
Your opponent has drawn a 10. You have won this round!
You have drawn 11.
Your opponent has drawn a 9. You have won this round!
***********************************************************************************************************************
Your final score is: 2
Your opponents final score is: 1
Congratulations! You've won the game!
import java.util.*;
public class CardGame5 {
public static void main(String[] args)
{
Random random = new Random();
int b = 0;
int c = 0;
double d;
System.out.println("Welcome to my card game!");
System.out.println("There is a fair, shuffles stack of cards in the middle of the table.");
System.out.println("You and your opponent will both draw a card, and the higher of the two cards wins.");
System.out.println("Cards are shuffled back into the deck after each round.");
System.out.println("The player who at the end of the game won most rounds wins the game.");
System.out.println("After you are done reading the current round, press enter to start a new round.");
System.out.println("***********************************************************************************************************************");
System.out.println("How many rounds would you like there to be?");
Scanner onin = new Scanner(System.in);
d=onin.nextInt();
System.out.println("***********************************************************************************************************************");
while (d > 0)
{
int a = random.nextInt(13) +2;
if (a == 2)
{
System.out.println("You have drawn 2.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. This round is a tie!");
d--;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You lose this round!");
d--;
c++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You lose this round!");
d--;
c++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You lose this round!");
d--;
c++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. You lose this round!");
d--;
c++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You lose this round!");
d--;
c++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You lose this round!");
d--;
c++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 3)
{
System.out.println("You have drawn 3.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. This round is a tie!");
d--;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You lose this round!");
d--;
c++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You lose this round!");
d--;
c++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. You lose this round!");
d--;
c++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You lose this round!");
d--;
c++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You lose this round!");
d--;
c++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 4)
{
System.out.println("You have drawn 4.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. This round is a tie!");
d--;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You lose this round!");
d--;
c++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. You lose this round!");
d--;
c++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You lose this round!");
d--;
c++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You lose this round!");
d--;
c++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 5)
{
System.out.println("You have drawn 5.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. This round is a tie!");
d--;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. You lose this round!");
d--;
c++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You lose this round!");
d--;
c++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You lose this round!");
d--;
c++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 6)
{
System.out.println("You have drawn 6.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. This round is a tie!");
d--;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You lose this round!");
d--;
c++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You lose this round!");
d--;
c++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 7)
{
System.out.println("You have drawn 7.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. This round is a tie!");
d--;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You lose this round!");
d--;
c++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 8)
{
System.out.println("You have drawn 8.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You have won this round!");
d--;
b++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. This round is a tie!");
d--;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You lose this round!");
d--;
c++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 9)
{
System.out.println("You have drawn 9.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You have won this round!");
d--;
b++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You have won this round!");
d--;
b++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. This round is a tie!");
d--;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You lose this round!");
d--;
c++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 10)
{
System.out.println("You have drawn 10.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You have won this round!");
d--;
b++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You have won this round!");
d--;
b++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You have won this round!");
d--;
b++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. This round is a tie!");
d--;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You lose this round!");
d--;
c++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 11)
{
System.out.println("You have drawn 11.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You have won this round!");
d--;
b++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You have won this round!");
d--;
b++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You have won this round!");
d--;
b++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You have won this round!");
d--;
b++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. This round is a tie!");
d--;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You lose this round!");
d--;
c++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 12)
{
System.out.println("You have drawn 12.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You have won this round!");
d--;
b++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You have won this round!");
d--;
b++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You have won this round!");
d--;
b++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You have won this round!");
d--;
b++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You have won this round!");
d--;
b++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. This round is a tie!");
d--;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. You lose this round!");
d--;
c++;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
else if (a == 13)
{
System.out.println("You have drawn 13.");
int e = random.nextInt(13) +2;
if (e == 2)
{
System.out.println("Your opponent has drawn 2. You have won this round!");
d--;
b++;
}
else if (e == 3)
{
System.out.println("Your opponent has drawn a 3. You have won this round!");
d--;
b++;
}
else if (e == 4)
{
System.out.println("Your opponent has drawn a 4. You have won this round!");
d--;
b++;
}
else if (e == 5)
{
System.out.println("Your opponents has drawn a 5. You have won this round!");
d--;
b++;
}
else if (e == 6)
{
System.out.println("Your opponent has drawn a 6. Your have won this round!");
d--;
b++;
}
else if (e == 7)
{
System.out.println("Your opponent has drawn a 7. You have won this round!");
d--;
b++;
}
else if (e == 8)
{
System.out.println("Your opponents has drawn a 8. You have won this round!");
d--;
b++;
}
else if (e == 9)
{
System.out.println("Your opponent has drawn a 9. You have won this round!");
d--;
b++;
}
else if (e == 10)
{
System.out.println("Your opponent has drawn a 10. You have won this round!");
d--;
b++;
}
else if (e == 11)
{
System.out.println("Your opponents has drawn a 11. You have won this round!");
d--;
b++;
}
else if (e == 12)
{
System.out.println("Your opponent has drawn a 12. You have won this round!");
d--;
b++;
}
else if (e == 13)
{
System.out.println("Your opponent has drawn a 13. This round is a tie!");
d--;
}
Scanner keyboard = new Scanner(System.in);
keyboard.nextLine();
}
//tähän perkule!
}
System.out.println("***********************************************************************************************************************");
System.out.println("Your final score is: " +b);
System.out.println("Your opponents final score is: " +c);
if (d == 0)
{
if (b > c)
{
System.out.println("Congratulations! You've won the game!");
}
else if (c > b)
{
System.out.println("Oh no! You've lost the game! :(");
}
else if (c == b)
{
System.out.println("The game is a draw. What a climax!");
}
}
}
}
Page created in 0.050 seconds with 23 queries.