Results 1 to 3 of 3
- 03-19-2014, 09:42 PM #1
Member
- Join Date
- Mar 2014
- Posts
- 2
- Rep Power
- 0
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ış
}
}
- 03-19-2014, 09:45 PM #2
Member
- Join Date
- Mar 2014
- Posts
- 2
- Rep Power
- 0
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ış
}
}
- 03-19-2014, 10:10 PM #3
Similar Threads
-
multiplayer LAN game
By ethomas92 in forum NetworkingReplies: 1Last Post: 12-14-2012, 08:54 PM -
single player Blackjack no dealer
By RvcaGuy in forum New To JavaReplies: 1Last Post: 11-10-2011, 11:55 PM -
Multiplayer Bingo game
By js4learn in forum Java GamingReplies: 1Last Post: 07-08-2011, 03:43 AM -
Multiplayer Game(Sockets)
By kevinnrobert in forum Java GamingReplies: 1Last Post: 04-02-2010, 01:22 PM -
Multiplayer BlackJack Applet
By lostwake in forum Java AppletsReplies: 0Last Post: 07-23-2009, 11:04 PM
Bookmarks