JAVA Learning Group
- JustAnyone
- Developer
- Reactions:
- Posts: 3480
- Joined: 23 Jul 2017, 12:45
- Location: Easter Island
- Plugins: Showcase Store
-
Platform
Re: JAVA Learning Group
IT'S ALIVE
Finally managed to make your code into .json file.[/i}
...
Finally managed to make your code into .json file.[/i}
...
- Xim
- Inhabitant of a Megalopolis
- Reactions:
- Posts: 600
- Joined: 04 Sep 2017, 14:17
- Location: Somewhere in Sometime
- Plugins: Showcase Store
-
Platform
Re: JAVA Learning Group
Meanwhile several nuclear wars has startedJustAnyone wrote: ↑17 Dec 2017, 00:28IT'S ALIVE
Finally managed to make your code into .json file.[/i}
...
If u say i am controlling DSA i m not
My country dont exist right now
DSA:....
- JustAnyone
- Developer
- Reactions:
- Posts: 3480
- Joined: 23 Jul 2017, 12:45
- Location: Easter Island
- Plugins: Showcase Store
-
Platform
Re: JAVA Learning Group
it's "JAVA LEARNING GROUP" not country complainant department.
- Brody Craft
- Inhabitant of a Infinity
- Reactions:
- Posts: 8034
- Joined: 24 Jan 2017, 11:15
- Location: SE Asia
- Plugins: Showcase Store
- Version: Beta
-
Platform
Re: JAVA Learning Group
in general. Stop offtopic.
- JustAnyone
- Developer
- Reactions:
- Posts: 3480
- Joined: 23 Jul 2017, 12:45
- Location: Easter Island
- Plugins: Showcase Store
-
Platform
Re: JAVA Learning Group
1.3 Update is now available for Plugin Creator.
- Bearbear76
- Former Bearbear65
- Reactions:
- Posts: 5730
- Joined: 10 Feb 2017, 14:53
- Location: L2 cache
- Plugins: Showcase Store
-
Plugin Creator
Platform
Re: JAVA Learning Group
made a simple blackjack
but I didn't know how to make a balance of money that decreases when you lose
and increases when you win. everything I tried resets when I click run
but I didn't know how to make a balance of money that decreases when you lose
and increases when you win. everything I tried resets when I click run
Code: Select all
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Random;
public class BlackJack {
Random User = new Random();
public static void main(String[] agrs) {
Random User = new Random();
Random Bot = new Random();
Scanner Hit = new Scanner(System.in);
Scanner Bet = new Scanner(System.in);
ArrayList<Integer> UserCards = new ArrayList<Integer>();
ArrayList<Integer> BotCards = new ArrayList<Integer>();
String hit;
int bet;
int bal = 500;
int UserDeck;
int BotDeck;
int UserSum = 0;
int BotSum = 0;
System.out.println("How much will you bet?\n" + "Remaining: " + bal + "$");
bet = Bet.nextInt();
if (bet > bal) {
System.out.println("You don't have that much money left...");
}
else if (bet >= 10) {
UserDeck = User.nextInt(13)+1;
UserCards.add(UserDeck);
System.out.println("Type hit to draw another card, type stand to pass.\n\nYour cards.\n"+ UserDeck +"\n");
BotDeck = Bot.nextInt(13)+1;
BotCards.add(BotDeck);
System.out.println("Bot's cards\n"+ BotDeck);
hit = Hit.nextLine();
while (hit.equals("hit")) {
UserDeck = User.nextInt(13)+1;
UserCards.add(UserDeck);
BotDeck = Bot.nextInt(13)+1;
BotCards.add(BotDeck);
for(int i : UserCards)
UserSum += i;
for(int ii : BotCards)
BotSum += ii;
System.out.println("\n\nYour cards.\n" + UserSum + "\n");
System.out.println("bots cards.\n" + BotSum + "\n");
if(UserSum == 21) {
System.out.println("Black Jack!" + bet + " x2");
bal = bal + bet * 2;
break;
}
else if (UserSum > 21) {
if (BotSum > 21) {
System.out.println("Draw");
break;
}
else if (UserSum > 21) {
if (BotSum < 21) {
System.out.println("You lost..." + bet);
bal = bal - bet;
break;
}
}
else if (BotSum > 21){
if (UserSum < 21) {
System.out.println("You won" + bet);
bal = bal + bet;
break;
}
}
}
hit = Hit.nextLine();
}
if (BotSum < UserSum) {
BotDeck = Bot.nextInt(13)+1;
BotCards.add(BotDeck);
}
if (!hit.equals("hit")){
if (UserSum > BotSum) {
if (UserSum < 21) {
System.out.println("You won!" + bet);
bal = bal + bet;
}
}
else if (UserSum < BotSum){
if (BotSum < 21) {
System.out.println("You Lost..." + bet);
bal = bal - bet;
}
}
else if (UserSum == BotSum) {
System.out.println("Draw");
}
else if (BotSum > UserSum) {
if (BotSum > 21) {
if(UserSum < 21) {
System.out.println("You won!" + bet);
bal = bal + bet;
}
}
else if (UserSum > 21) {
if (BotSum > 21) {
System.out.println("Draw");
}
}
}
}
}
else
System.out.println("You must bet more then 10$");
System.out.println("Remaining: " + bal + "$");
}
}
Last edited by Bearbear76 on 24 Mar 2018, 13:18, edited 1 time in total.
- Brody Craft
- Inhabitant of a Infinity
- Reactions:
- Posts: 8034
- Joined: 24 Jan 2017, 11:15
- Location: SE Asia
- Plugins: Showcase Store
- Version: Beta
-
Platform
Re: JAVA Learning Group
Add that to TT's code if its possible.
- JustAnyone
- Developer
- Reactions:
- Posts: 3480
- Joined: 23 Jul 2017, 12:45
- Location: Easter Island
- Plugins: Showcase Store
-
Platform
Re: JAVA Learning Group
Why would TheoTown need a blackjack?
- Brody Craft
- Inhabitant of a Infinity
- Reactions:
- Posts: 8034
- Joined: 24 Jan 2017, 11:15
- Location: SE Asia
- Plugins: Showcase Store
- Version: Beta
-
Platform
Re: JAVA Learning Group
Test.