0% found this document useful (0 votes)
36 views

Import Public Class Public Static Void New New Int Int Double Int

The document describes a card game program where two players draw random cards each round to determine a winner. The program tracks each player's score over multiple rounds, displays the card drawn and winner of each round, and identifies the overall winner once all rounds are complete.

Uploaded by

Iulik Bruma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Import Public Class Public Static Void New New Int Int Double Int

The document describes a card game program where two players draw random cards each round to determine a winner. The program tracks each player's score over multiple rounds, displays the card drawn and winner of each round, and identifies the overall winner once all rounds are complete.

Uploaded by

Iulik Bruma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

import java.util.

*; public class JavaCardGame { public static void main(String[] args) { Random random = new Random(); Scanner in = new Scanner(System.in); int b = 0; //my score int c = 0; //my opponent score double d; int f; System.out.println("Welcome to My Card Game! \nThere is a fair, shuffled 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 at the end of the game who won the most rounds is the winner of the game."); System.out.println("After you are done reading the current round, press enter to move on to the next 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(9) + 2; if (a == 2) { System.out.println("You have drawn a 6"); int e = random.nextInt(9) + 1; if ( e == 1) { System.out.println("Your opponent has drawn a 6, making this round a draw."); d--; } else if (e == 2) { System.out.println("Your opponent has drawn a 7, meaning you lost this round."); d--; c++; } else if (e == 3) { System.out.println("Your opponent has drawn a 8, meaning you lost this round."); d--; c++; } else if (e == 4)

{ System.out.println("Your opponent has drawn a 9, meaning you lost this round."); d--; c++; } else if (e == 5) { System.out.println("Your opponent round."); d--; c++; } else if (e == 6) { System.out.println("Your opponent round."); d--; c++; } else if (e == 7) { System.out.println("Your opponent round."); d--; c++; } else if (e == 8) { System.out.println("Your opponent round."); d--; c++; } else if (e == 9) { System.out.println("Your opponent round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine();

has drawn a 10,

meaning you lost this

has drawn a Jake,

meaning you lost this

has drawn a Queen,

meaning you lost this

has drawn a King,

meaning you lost this

has drawn an Ace,

meaning you lost this

} else if (a == 3) { System.out.println("You have drawn a 7"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has drawn a 6, meaning you won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has drawn a 7, making this round a draw."); d--; } else if (e == 3)

{ System.out.println("Your opponent has drawn a 8, meaning you lost this round."); d--; c++; } else if (e == 4) { System.out.println("Your opponent has drawn a round."); d--; c++; } else if (e == 5) { System.out.println("Your opponent has drawn a round."); d--; c++; } else if (e == 6) { System.out.println("Your opponent has drawn a round."); d--; c++; } else if (e == 7) { System.out.println("Your opponent has drawn a round."); d--; c++; } else if (e == 8) { System.out.println("Your opponent has drawn a round."); d--; c++; } else if (e == 9) { System.out.println("Your opponet has drawn an round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine();

9,

meaning you lost this

10,

meaning you lost this

Jake,

meaning you lost this

Queen,

meaning you lost this

King,

meaning you lost this

Ace.

meaning you lost this

} else if (a == 4) { System.out.println("You have drawn a 8"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has drawn a 6, meaning you won this round."); d--; b++; } else if (e == 2)

{ System.out.println("Your opponent has drawn a 7, meaning you won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has drawn a round a draw."); d--; } else if (e == 4) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 5) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 6) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 7) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 8) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 9) { System.out.println("Your opponet has drawn an lost this round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine(); } else if (a == 5) { System.out.println("You have drawn a 9"); int e = random.nextInt(9) +1; if (e == 1)

8,

making this

9,

meaning you

10,

meaning you

Jake,

meaning you

Queen,

meaning you

King,

meaning you

Ace.

meaning you

{ System.out.println("Your opponent has drawn a 6, meaning you won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has drawn a won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 4) { System.out.println("Your opponent has drawn a round a draw."); d--; } else if (e == 5) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 6) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 7) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 8) { System.out.println("Your opponent has drawn a lost this round."); d--; c++; } else if (e == 9) { System.out.println("Your opponet has drawn an lost this round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine();

7,

meaning you

8,

meaning you

9,

making this

10,

meaning you

Jake,

meaning you

Queen,

meaning you

King,

meaning you

Ace.

meaning you

meaning you

meaning you

meaning you

meaning you

making this

meaning you

meaning you

meaning you

} else if (a == 6) { System.out.println("You have drawn a 10"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has won this round."); d--; b++; } else if (e == 4) { System.out.println("Your opponent has won this round."); d--; b++; } else if (e == 5) { System.out.println("Your opponent has round a draw."); d--; } else if (e == 6) { System.out.println("Your opponent has lost this round."); d--; c++; } else if (e == 7) { System.out.println("Your opponent has lost this round."); d--; c++; } else if (e == 8) { System.out.println("Your opponent has lost this round."); d--; c++; } else if (e == 9) {

drawn a 6,

drawn a 7,

drawn a 8,

drawn a 9,

drawn a 10,

drawn a Jake,

drawn a Queen,

drawn a King,

System.out.println("Your opponet has drawn an Ace. meaning you lost this round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine(); } else if (a == 7) { System.out.println("You have drawn a Jake"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has drawn won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has drawn won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has drawn won this round."); d--; b++; } else if (e == 4) { System.out.println("Your opponent has drawn won this round."); d--; b++; } else if (e == 5) { System.out.println("Your opponent has drawn won this round."); d--; b++; } else if (e == 6) { System.out.println("Your opponent has drawn round a draw."); d--; } else if (e == 7) { System.out.println("Your opponent has drawn lost this round."); d--; c++; } else if (e == 8) {

a 6,

meaning you

a 7,

meaning you

a 8,

meaning you

a 9,

meaning you

a 10,

meaning you

a Jake,

making this

a Queen,

meaning you

System.out.println("Your opponent has drawn a King, meaning you lost this round."); d--; c++; } else if (e == 9) { System.out.println("Your opponet has drawn an lost this round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine(); } else if (a == 8) { System.out.println("You have drawn a Queen"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has drawn a won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 4) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 5) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 6) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 7) {

Ace.

meaning you

6,

meaning you

7,

meaning you

8,

meaning you

9,

meaning you

10,

meaning you

Jake,

meaning you

System.out.println("Your opponent has drawn a Queen, making this round a draw."); d--; } else if (e == 8) { System.out.println("Your opponent has drawn a King, lost this round."); d--; c++; } else if (e == 9) { System.out.println("Your opponet has drawn an Ace. lost this round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine(); } else if (a == 9) { System.out.println("You have drawn a King"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has drawn a 6, won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has drawn a 7, won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has drawn a 8, won this round."); d--; b++; } else if (e == 4) { System.out.println("Your opponent has drawn a 9, won this round."); d--; b++; } else if (e == 5) { System.out.println("Your opponent has drawn a 10, won this round."); d--; b++; } else if (e == 6) {

meaning you

meaning you

meaning you

meaning you

meaning you

meaning you

meaning you

System.out.println("Your opponent has drawn a Jake, meaning you won this round."); d--; b++; } else if (e == 7) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 8) { System.out.println("Your opponent has drawn a round a draw."); d--; } else if (e == 9) { System.out.println("Your opponet has drawn an lost this round."); d--; c++; } Scanner key = new Scanner(System.in); key.nextLine(); } else if (a == 10) { System.out.println("You have drawn an Ace"); int e = random.nextInt(9) +1; if (e == 1) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 2) { System.out.println("Your opponent has drawn a won this round. "); d--; b++; } else if (e == 3) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 4) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 5) {

Queen,

meaning you

King,

making this

Ace.

meaning you

6,

meaning you

7,

meaning you

8,

meaning you

9,

meaning you

System.out.println("Your opponent has drawn a 10, meaning you won this round."); d--; b++; } else if (e == 6) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 7) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 8) { System.out.println("Your opponent has drawn a won this round."); d--; b++; } else if (e == 9) { System.out.println("Your opponet has drawn an round a draw."); d--; } Scanner key = new Scanner(System.in); key.nextLine(); } } System.out.println("Your final score is: " +b); System.out.println("Your's opponent final score is: " +c); if (b>c) { System.out.println("Great job, You've won!"); } else if (b == c) { System.out.println("You have tied with your opponent"); } else if (b<c) { System.out.println("Your opponent beat you"); }

Jake,

meaning you

Queen,

meaning you

King,

meaning you

Ace,

making this

} }

You might also like