JAVA Learning Group

Here you can talk about everything you want.
User avatar
JustAnyone
Developer
Reactions:
Posts: 3470
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: JAVA Learning Group

#101

Post by JustAnyone »

IT'S ALIVE
Finally managed to make your code into .json file.[/i}
...It's in version 1.2[/sicret]

User avatar
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

#102

Post by Xim »

JustAnyone wrote:
17 Dec 2017, 00:28
IT'S ALIVE
Finally managed to make your code into .json file.[/i}
...It's in version 1.2[/sicret]
Meanwhile several nuclear wars has started
If u say i am controlling DSA i m not



My country dont exist right now
DSA:....

User avatar
JustAnyone
Developer
Reactions:
Posts: 3470
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: JAVA Learning Group

#103

Post by JustAnyone »

it's "JAVA LEARNING GROUP" not country complainant department.

User avatar
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

#104

Post by Brody Craft »

in general. Stop offtopic.

User avatar
JustAnyone
Developer
Reactions:
Posts: 3470
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: JAVA Learning Group

#105

Post by JustAnyone »

1.3 Update is now available for Plugin Creator.

User avatar
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

#106

Post by Bearbear76 »

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

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.

User avatar
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

#107

Post by Brody Craft »

Add that to TT's code if its possible.

User avatar
JustAnyone
Developer
Reactions:
Posts: 3470
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: JAVA Learning Group

#108

Post by JustAnyone »

Why would TheoTown need a blackjack? :D

User avatar
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

#109

Post by Brody Craft »

Test.

Locked Previous topicNext topic

Return to “Smalltalk”