JAVA Learning Group

Here you can talk about everything you want.
Online
User avatar
JustAnyone
Feature manager
Reactions:
Posts: 2156
Joined: Sun Jul 23, 2017 12:45
Location: Phone repair service
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi 3s

Re: JAVA Learning Group

Post by JustAnyone » Sun Dec 17, 2017 0:28

IT'S ALIVE
Finally managed to make your code into .json file.[/i}
...It's in version 1.2[/sicret]
Founder and owner of DSA
TheoTown discord manager
Developer of Plugin Creator Application.

Xim
Inhabitant of a Megalopolis
Reactions:
Posts: 613
Joined: Mon Sep 04, 2017 14:17
Location: Somewhere in Sometime
Plugins: Show

Re: JAVA Learning Group

Post by Xim » Wed Dec 20, 2017 16:03

JustAnyone wrote:
Sun Dec 17, 2017 0: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:....
No signature

Online
User avatar
JustAnyone
Feature manager
Reactions:
Posts: 2156
Joined: Sun Jul 23, 2017 12:45
Location: Phone repair service
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi 3s

Re: JAVA Learning Group

Post by JustAnyone » Wed Dec 20, 2017 19:24

it's "JAVA LEARNING GROUP" not country complainant department.
Founder and owner of DSA
TheoTown discord manager
Developer of Plugin Creator Application.

User avatar
Brody Craft
Inhabitant of a Multiverse
Reactions:
Posts: 6675
Joined: Tue Jan 24, 2017 11:15
Location: SE Asia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy Tab 3

Re: JAVA Learning Group

Post by Brody Craft » Thu Dec 21, 2017 4:27

in general. Stop offtopic.
Do you want guns?
[youtube]https://youtube.com/watch?v=nk7Cj209GQg[/youtube]
28.49%

Online
User avatar
JustAnyone
Feature manager
Reactions:
Posts: 2156
Joined: Sun Jul 23, 2017 12:45
Location: Phone repair service
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi 3s

Re: JAVA Learning Group

Post by JustAnyone » Sat Dec 23, 2017 17:26

1.3 Update is now available for Plugin Creator.
Founder and owner of DSA
TheoTown discord manager
Developer of Plugin Creator Application.

User avatar
Bearbear65
Inhabitant of a Universe
Reactions:
Posts: 4363
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta
Phone model: ASUS ZenPad 10 z300c

Re: JAVA Learning Group

Post by Bearbear65 » Sat Mar 24, 2018 12:28

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 Bearbear65 on Sat Mar 24, 2018 13:18, edited 1 time in total.
ImageJust my opinion

User avatar
Brody Craft
Inhabitant of a Multiverse
Reactions:
Posts: 6675
Joined: Tue Jan 24, 2017 11:15
Location: SE Asia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy Tab 3

Re: JAVA Learning Group

Post by Brody Craft » Sat Mar 24, 2018 12:30

Add that to TT's code if its possible.
Do you want guns?
[youtube]https://youtube.com/watch?v=nk7Cj209GQg[/youtube]
28.49%

Online
User avatar
JustAnyone
Feature manager
Reactions:
Posts: 2156
Joined: Sun Jul 23, 2017 12:45
Location: Phone repair service
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi 3s

Re: JAVA Learning Group

Post by JustAnyone » Sat Mar 24, 2018 15:21

Why would TheoTown need a blackjack? :D
Founder and owner of DSA
TheoTown discord manager
Developer of Plugin Creator Application.

User avatar
Brody Craft
Inhabitant of a Multiverse
Reactions:
Posts: 6675
Joined: Tue Jan 24, 2017 11:15
Location: SE Asia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy Tab 3

Re: JAVA Learning Group

Post by Brody Craft » Sat Mar 24, 2018 15:33

Test.
Do you want guns?
[youtube]https://youtube.com/watch?v=nk7Cj209GQg[/youtube]
28.49%

Post Reply Previous topicNext topic

Return to “Smalltalk”

Who is online

Users browsing this forum: Kulche and 1 guest