Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Game Pontoon

Have Programming Question? Ask it here!
 
 
 


David Ferguson
Java Game Pontoon
1 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


Could someone help me create a programme for the game pontoon

//play a game of pontoon import java.util.*;

public class Pontoon { public static void main (String args[]) { //deal initial hands //deal additional cards to player //deal additional cards to computer //check if anyone bust //check for winner if no-one bust } }

//method header for method to deal a card

public static int dealCard() { }

//generate random value in range 1 ? 13
int rank = (int)(Math.random() * 13 ) + 1;

//loop until no more cards required while (anotherCard.equalsIgnoreCase("y")) { }


Advertisement
View Answers

November 8, 2011 at 12:53 PM


import java.util.Scanner;

public class Pontoon{

     public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int playerScore = 0, computerScore = 0;
        String newCard = "";
        playerScore += dealCard();
        computerScore += dealCard();
        playerScore += dealCard();
        computerScore += dealCard();

        System.out.printf("Your score is %d would you like another card ? y/n ", playerScore);
        newCard = input.nextLine();
        if(newCard.equalsIgnoreCase("Y")) {
            while (newCard.equalsIgnoreCase("Y")) {
                playerScore += dealCard();
                System.out.printf("Your score is %d would you like another card ? y/n ", playerScore);
                newCard = input.nextLine();
            }
        }
        while(computerScore < 15){
            computerScore += dealCard();
        }
        checkWin(playerScore, computerScore);
    }
    public static int dealCard(){
        int value = (int) (Math.random() * 13) + 1;
        int score = 0;
        if(value == 1) {
            System.out.println("Ace!");
            score = 11;
        }else if (value == 13) {
            System.out.println("King!");
            score = 10;
        }else if (value == 12) {
            System.out.println("Queen!");
            score = 10;
        } else if (value == 11) {
            System.out.println("Jack!");
            score = 10;
        } else {
            score = value;
        }

        return score;
    }

    public static void checkWin(int Player, int Computer) {
        int player = Player;
        int computer = Computer;

        if (player > 21) {
            System.out.println("Player Bust");
        } else if (computer > 21) {
            System.out.println("Computer Bust");
        } else {
            if (player > computer) {
                System.out.println("Player Wins!");
            } else {
                System.out.println("Computer Wins!");
            }
        }
    }
}


Related Tutorials/Questions & Answers:
Java Game Pontoon
Java Game Pontoon  Could someone help me create a programme for the game pontoon //play a game of pontoon import java.util.*; public class Pontoon { public static void main (String args[]) { //deal initial hands
Java game Pontoon
Java game Pontoon  Hello. I have trouble with my pontoon code. I ahve done it using simple java programming. It is working BUT it dosent stops when the players hand rises ober 24 points. where in game the player should be bust
Advertisements
JAVA PONTOON
JAVA PONTOON  when this code is run it just continues. It needs to stop at 21 Or then say bust. Is someone able to help PLEASE :-) import java.util.Scanner; public class Pontoon{ public static void main(String[] args
Pontoon
Pontoon  I have this code.. To play a game of Pontoon (Blackjack) i want to be able to reach the number of 21 and then stop. This does... for no. import java.util.Scanner; public class Pontoon { public static void main
java game
java game  Can anyone please give me a game source code
JAVA Game
JAVA Game  I want to make a JAVA game...in dat game...d player has to input a word in 10 secnds...4 dat m running a delay loop... but the problem is not...i am not getting any way...to make that input field(eg: String str
Game
Game  How to develop a game using java? give me a total code for any simple game
game Nim - Java Beginners
game Nim  how is the search tree for a game Nim looks like
game
game  How to make 3D game in java Applet
Game
Game  how can create simple game in java . thank u so match ,please help
Create a Swamp Game in Java
Create a Swamp Game in Java  You are to create a game called ‚??Get Out of My Swamp‚??. In this game an ogre, called ‚??Hek‚??, wanders around his... two ogre enemies in the same place they kill the ogre and the game ends. Full
game
game  Hi thank you for answers.I am devoloping a java game caled Duck Hunt Game in netbeans6.7.1 software and I need help in some codes...,if you have this game's code please post me as soon as possible
Java program for connectfour game
Java program for connectfour game  Hello, my program is about connectFour game. I need help with resolving the logic for this problem. I appreciate...; ConnectFourServer game = new ConnectFourServer(); private ConnectFourClient
Craps Game Java Programming Help
Craps Game Java Programming Help  Craps is a casino game that involves the throwing of a pair of dice. Based on the throw, the thrower either gets to continue throw (and win money), or stops throwing (and loses money). Write your
Java game bulls and cows
Java game bulls and cows In this tutorial, you will learn how to implement bulls and cows game in java. The game bulls and cows is an ancient game...;quit", the user will come out from the game. If the user inputs 4 digit
who know full coding of guessing game in java?
who know full coding of guessing game in java?  There is only 1 player. Use JAVA Random toolkit to generate random number between 1 to 10. Once user... again or to exit the game by type 1 to proceed the game and type 2 to end the game
BRICK-BREAKER game concept - Java Beginners
BRICK-BREAKER game concept  I am planning to write a program for BRICK-BREAKER GAME. can any 1 help me any 1 can u plz help me frzzz?? you can also send the mails to poramboku.me@gmai.com
genaral snake game in java - Java Beginners
genaral snake game in java  can u please send code for fallowing write a snake game program using swings?  Hi This is the source code of Snake game in swing Snake.java file import javax.swing.JFrame
tetris game code - Swing AWT
tetris game code  To develop a JAVA puzzle game which is a "variation" of the Tetris game
game programming
game programming  Hi. i have witten the script and have almost completed developing a social game like mafia wars. can any one plz help me by answering me some of my doubts.. after uploading the game on facebook how tokeep data
Blackjack game - IDE Questions
Blackjack game  Create a java code for a simple blackjack game for just one hand of Blackjack, it does not need to include money and betting
Chess Game
Chess Game  How could I make a basic 8x8 chess table with two dimensional arrays and insert the chess pieces in the array?   Please visit the following link: http://roseindia.net/java/example/java/swing/chess
Create a guessing game - Framework
Create a guessing game  Create a guessing game that picks a random number between 1 and 100 and lets you keep guessing until you get it right! You..., too. it is in java but i m not sure about the language, it is like c.print
How do i slow down the game (othello game)??
How do i slow down the game (othello game)??  Hello, I built an othello game that can be played by 2 humans , human and computer and two computers... with each other the fram doesn't appear until the game is finish. I think it is becase
Can anyone assist with the coding of this game?
Can anyone assist with the coding of this game?  I am in need of the coding for this game. I need to write a "Hangman" game that will randomly generate a word from a text file and will prompt the user to guess one letter
game programming code - Swing AWT
game programming code  write a snake program using swings with step by step explanation?. please send me this source code to my mail id with step by step explanation
Two user chess game - Applet
Two user chess game  Write a program for a two user chess game(Users must be on different systems)? please send me this source code to my mail id with step by step explanation
XP Bowling Game User input help
XP Bowling Game User input help  I was asked to do the XP Bowling Example as an assignment. I have the programme passing all tests, but now I need... in a command window. Being new to Java....I have no clue how to out put it to the console
How to design a little game
How to design a little game In this example we are going to design a little game which is used by the children easily. New File: Take a new file with appropriate size. Rounded Rectangle Tool: Choose Rounded Rectangular
Game and Graphic Books
Game and Graphic Books         Computer Game Developer I've always thought game developers were born, not made. True greatness comes from within
plz help me to write a snake game using swings - Swing AWT
plz help me to write a snake game using swings  write snake game program using swings
Get Your Game on with SuperGamer-1
Get Your Game on with SuperGamer-1 Gaming in Linux is much easier than it once was... These last days it's become easier to game in Linux than in Windows. Now all that's required is booting a DVD. The SuperGamer-1 is a modification
How to design a remote of the game.
How to design a remote of the game.       Hey, do you want to brush up your designing skill? Then come forward to design a video game remote by using Photoshop. This tutorial
Guess Number Games in Java
Guess Number Games in Java Here we are going to create guess number game where user have to guess the randomly generated number. For this, we have allowed... will like to quit from the game, you can press 'quit'button.   Here
20 question Game involving recursive methods
20 question Game involving recursive methods  I have a problem with compiling my program. Any help please. My code of line where it says "Node first = question.new Node()" i get the error"String.Node cannot be resolved
Chess Application In Java Swing
.style1 { margin-right: 0px; } Chess Application In Java Swing       In this section, you will learn how to create chess game in java swing
iPhone Game Applications Development, iPhone Game Porting Services, iPhone Game Designing
iPhone Game Applications Development iPhone Game Development.... Benefits of iPhone Game Development There are many benefits.... Features of Rose India iPhone Game Development Services Rose
Code rally
; A Java-based, real-time programming game based on the Eclipse platform. What is CodeRally? CodeRally is a Java?-based, real-time programming game based... that allows users unfamiliar with Java to easily compete while they learn the Java
Java ME
Java ME        ... of entertainment in the real life because mobile game is user friendly and portable.... As a result, graphics are getting better and similarly game play is getting
java - Swing AWT
java   Write Snake Game using Swings
Mobile Game Developers
Mobile Game Developers A mobile game is very different from handheld video game that is played on PlayStation portable or with remote on television or computer. A mobile game here refers to a video game played on a mobile phone
Open Source Game Engine
Open Source Game Engine Genesis3D Open Source Engine Genesis3D...-featured game engine. It is being developed to fulfill the needs of military training...: A HLA networking component for the Game Manager that support an Agile FOM interface
Flex Mobile Phone Game Development
Flex Mobile Phone Game Development Games are always mean of entertainment... that specializes in Flex mobile phone game development for all types of mobile phones... team of Flex Mobile Phone Game Development that comprises from super specialists
Top 10 Java Applications
Java is the wonder programming language that is widely used for most of the modern day computing jobs, from designing websites to game applications to preparing interactive video to any other application jobs. Without java applications we
Mobile J2ME Game Development Services, J2ME Mobile Game Application Solutions, Mobile Games Development
Mobile J2ME Game Development J2ME Mobile Games Development Solutions from Rose... time. Rose India is a mobile game development games company that has mastered the J2ME game application development platform to deliver immersive 3D based
iPhone Game Development Company
iPhone Game Development Company Since the evaluation of the video games... to the addiction of playing games. The game industry is booming day by day and thousands of new games are being introduced by game development companies across
Sudoku program - Java Beginners
Sudoku program  I would like to get the program for 9X9 Sudoku game in JAVA
Java Memory Leak - Java Beginners
Java Memory Leak  I am having a memory leak in my java version of the game Snake. I have narrowed the exact step of when the program memory is increased to two possible points. The last step before the my game timer runs
java program
java program  hello.. do u all have any source to do the java programming for Snake and Ladder Game or any reservation system.. help me plz
java
java  what is the need of java if java is not there what will happen... work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles
Advertisements
 

 

 

DMCA.com