News:

Apachefoorumi.net
Raikasta ja ravitsevaa sielunruokaa.

Main Menu

Post reply

The message has the following error or errors that must be corrected before continuing:
Warning: this topic has not been posted in for at least 356 days.
Unless you're sure you want to reply, please consider starting a new topic.
Note: this post will not display until it has been approved by a moderator.
Other options
Verification:
Please leave this box empty:

What is the name of this forum?:
What is the most visible color in our forum?:
Shortcuts: ALT+S post or ALT+P preview

Topic summary

Posted by Ziperia
 - Fri 11.05.2012 00:06:34 (UTC+0300)
Tässä on uusi, siistitympi koodi. Kumman kun ei alunperin tullut ollenkaan ajatelleeksi tehdä helpomman kautta, kuitenkin yleensä tajuan laiskimman vaihtoehdon työssä kuin työssä. :psp:
Spoiler
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..");
}
}

}
[close]

Merkkien määrä putosi ~20000 noin 1600. Kiitos vinkistä :good:


Mtiä tähän bugiin tulee, niin havaitsen erään frendini kanssa että se ilmeni vain silloin, kun testasin peliä Eclipse ohjelmassa ja painoin enteriä (next round) pohjassa. rivi kerrallaan pelatessa mitään ongelmia ei missään vaiheessa tullut, joten kohtuu luottavaisesti oletan ongelman johtuneen tästä enterin pohjassa painamisesta, jolloin ohjelma toisti pelaajan vuoron muutaman kerran putkeen.
Posted by Ziperia
 - Thu 10.05.2012 13:30:03 (UTC+0300)
Jep kokeilen korjailla tuota hieman tänään, postailen myöhemmin tuloksia.
Posted by Lexa
 - Thu 10.05.2012 08:36:05 (UTC+0300)
Löyliksen kanssa samoilla linjoilla.. Eiköhän koodin tarkoitus ole pitkälti juurikin se ettei tarvitse jokaista mahdollista korttiyhdistelmää erikseen koodata ja testata ajovaiheessa. Miten ois esimerkiksi jotenkin että, Oma kortti - Vastustajan kortti = X. Jos X on tasan 0, tuli tasapeli, jos >0 voitit, jos <0 hävisit...
Posted by Susey
 - Wed 09.05.2012 22:16:52 (UTC+0300)
else
homma kusee :psycho:
Posted by Löylyttäjä
 - Wed 09.05.2012 21:16:28 (UTC+0300)
Java ei ole tuttu mutta nopeasti vilkaisemalla sanoisin että ehtolauseissa on jotain vikaa :think:
Ja eikö tuota nyt helpommin olisi voinut tehdä, pseudokoodina esitän perusperiaatteen :psp:
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
Posted by Ziperia
 - Mon 07.05.2012 22:52:09 (UTC+0300)
Aloitin tässä viikonloppun omatoimisesti opettelemaan koodaamaan javaa (En ole koskaan millään kielellä koodannut, kehotettiin aloittamaan joko javalla tai c#:llä).
Olen tässä tänään väsäillyt tälläistä perusharjoitusta jossa on tarkoitus tehdä korttipeli. Pelaat konetta vastaan, molemmat vetää vuorotellen pakasta kortin ja suurempi kortti voittaa rundin.

Koodi tuntuu toimivan hyvin ainakin aluksi, mutta välillä tapahtuu tällä tavalla että pelaaja vetää useita kortteja putkeen pakasta:
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!


Spoilerin takaa löytyy koodi kokonaisena, jos sitä viitsii joku vilkaista.
Spoiler
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!");
}
}
}

}
[close]