Results 1 to 3 of 3
  1. #1
    ruth133 is offline Member
    Join Date
    Mar 2014
    Posts
    2
    Rep Power
    0

    Default Turning single player blackjack game into multiplayer

    Hi everyone,

    I wrote a single player blackjack code and i want to play this game with multiplayers, which steps should i take to do this ? If anyone can turn this code into multiplayer, it would be appreciated. Cheers.

    package blackjack;

    import java.util.Random;
    import java.util.Scanner;

    public class Blackjack {

    public static void main(String[] args) {
    Random kagit=new Random ();
    Scanner veri = new Scanner (System.in);

    int bet;
    int money=500;
    int game;
    int sorgu=0;
    boolean ok = false;
    boolean goon = false;

    while(goon==false){
    System.out.println("Press 1 to play ,2 to quit");
    game=veri.nextInt();
    if(game==2){
    System.out.println("Goodbye!! Your balance: "+money); break;}
    System.out.printf("Starting money : %d\nYour bet:",money);
    bet=veri.nextInt();
    if(bet>money){
    System.out.println("Insufficient money. Re-enter bet!"); continue;}
    money-=bet;
    int k1=1+kagit.nextInt(11);
    int k2=1+kagit.nextInt(11);
    int kagittoplam=k1+k2;
    System.out.println("Your hand total: "+kagittoplam+" Your cards: "+k1+" and "+k2);

    while(ok==false){

    if(kagittoplam==21){
    money=money+bet*3;
    System.out.println("You win!\nYour balance: "+money);

    break;}
    else if (kagittoplam>21){
    System.out.println("You lose");
    System.out.println("Your balance: "+money);
    break;}
    else
    System.out.println("Stand (1)/ Hit(2)");
    sorgu=veri.nextInt();

    switch (sorgu) {
    case 1:
    System.out.printf("Your hand total: %d ***Goodbye***",kagittoplam);
    if(kagittoplam>=18){
    money=money+bet*2;}
    System.out.println("Your balance: "+money);
    ok=true;
    break;

    case 2:
    int k3=1+kagit.nextInt(11);
    System.out.println("New card:"+k3);
    kagittoplam+=k3; System.out.println("New total :"+kagittoplam);

    break;
    }// end switch

    }// end while iÁ
    ok=false;
    if(money>=2000){
    System.out.println("You reach 2000, congratulations!!"); break;}
    else if (money<=0){
    System.out.println("Insufficient money.Game over."); break;}

    }// end while dış
    }

    }

  2. #2
    ruth133 is offline Member
    Join Date
    Mar 2014
    Posts
    2
    Rep Power
    0

    Default Turning single player blackjack game into multiplayer

    Hi everyone,

    I wrote a single player blackjack code and i want to play this game with multiplayers, which steps should i take to do this ? If anyone can turn this code into multiplayer, it would be appreciated. Cheers.

    package blackjack;

    import java.util.Random;
    import java.util.Scanner;

    public class Blackjack {

    public static void main(String[] args) {
    Random kagit=new Random ();
    Scanner veri = new Scanner (System.in);

    int bet;
    int money=500;
    int game;
    int sorgu=0;
    boolean ok = false;
    boolean goon = false;

    while(goon==false){
    System.out.println("Press 1 to play ,2 to quit");
    game=veri.nextInt();
    if(game==2){
    System.out.println("Goodbye!! Your balance: "+money); break;}
    System.out.printf("Starting money : %d\nYour bet:",money);
    bet=veri.nextInt();
    if(bet>money){
    System.out.println("Insufficient money. Re-enter bet!"); continue;}
    money-=bet;
    int k1=1+kagit.nextInt(11);
    int k2=1+kagit.nextInt(11);
    int kagittoplam=k1+k2;
    System.out.println("Your hand total: "+kagittoplam+" Your cards: "+k1+" and "+k2);

    while(ok==false){

    if(kagittoplam==21){
    money=money+bet*3;
    System.out.println("You win!\nYour balance: "+money);

    break;}
    else if (kagittoplam>21){
    System.out.println("You lose");
    System.out.println("Your balance: "+money);
    break;}
    else
    System.out.println("Stand (1)/ Hit(2)");
    sorgu=veri.nextInt();

    switch (sorgu) {
    case 1:
    System.out.printf("Your hand total: %d ***Goodbye***",kagittoplam);
    if(kagittoplam>=18){
    money=money+bet*2;}
    System.out.println("Your balance: "+money);
    ok=true;
    break;

    case 2:
    int k3=1+kagit.nextInt(11);
    System.out.println("New card:"+k3);
    kagittoplam+=k3; System.out.println("New total :"+kagittoplam);

    break;
    }// end switch

    }// end while iÁ
    ok=false;
    if(money>=2000){
    System.out.println("You reach 2000, congratulations!!"); break;}
    else if (money<=0){
    System.out.println("Insufficient money.Game over."); break;}

    }// end while dış
    }

    }

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Turning single player blackjack game into multiplayer

    Threads merged.

    Please edit your post and wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. multiplayer LAN game
    By ethomas92 in forum Networking
    Replies: 1
    Last Post: 12-14-2012, 09:54 PM
  2. single player Blackjack no dealer
    By RvcaGuy in forum New To Java
    Replies: 1
    Last Post: 11-11-2011, 12:55 AM
  3. Multiplayer Bingo game
    By js4learn in forum Java Gaming
    Replies: 1
    Last Post: 07-08-2011, 04:43 AM
  4. Multiplayer Game(Sockets)
    By kevinnrobert in forum Java Gaming
    Replies: 1
    Last Post: 04-02-2010, 02:22 PM
  5. Multiplayer BlackJack Applet
    By lostwake in forum Java Applets
    Replies: 0
    Last Post: 07-24-2009, 12:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •