• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps help.please!

for my school assingment i have to make an android application for a card game-black jack.yes,i have found different and so many source codes on the web but when i copy them in my eclipse there always seems to be an error.
since i don't have time to learn the basis for java NOW(but i will,because i'm very interested in it) i am really hoping that someone can explain me how to make it work.
 
here is one source code:

Code:
package com.bj.android.bj;
 
 import java.io.*;
 
 public class BlackjackActivity
 {
 public static void main(String[] args) throws IOException
 {
 
 BufferedReader dataIn = new BufferedReader (new InputStreamReader(System.in));
 
 //Declare Variables
 int again = 0;
 do
 {
 double range = 26;
 int randomGenNum;
 int kitty = 1000;
 int yourBet;
 int userHandValue = 0;
 int userDrawnValue;
 int dealerHandValue = 0;
 int dealerDrawnValue;
 String playAgain;
 String hit = "";
 String strBetAmount;
 String userCard, dealerCard;
 
 int[] arrayCardValues =  {0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
 String[] arrayCardSuites =
 {
 "","","Ace/Clubs","Ace/Diamonds","Ace/Hearts","Ace/Spades",
 "2/Clubs","2/Diamonds","2/Hearts","2/Spades","3/Clubs","3/Diamonds","3/Hearts","3/Spades",
 "4/Clubs","4/Diamonds","4/Hearts","4/Spades","5/Clubs","5/Diamonds","5/Hearts","5/Spades",
 "6/Clubs","6/Diamonds","6/Hearts","6/Spades","7/Clubs","7/Diamonds","7/Hearts","7/Spades",
 "8/Clubs","8/Diamonds","8/Hearts","8/Spades","9/Clubs","9/Diamonds","9/Hearts","9/Spades",
 "10/Clubs","10/Diamonds","10/Hearts","10/Spades","Jack/Clubs","Jack/Diamonds","Jack/Hearts","Jack/Spades"
 ,"Queen/Clubs","Queen/Diamonds","Queen/Hearts","Queen/Spades","King/Clubs","King/Diamonds","King/Hearts","King/Spades"
 };
 
 //ask the user how much they want to bet
 System.out.println("How much do you want to bet?");
 strBetAmount = dataIn.readLine();
 yourBet = Integer.parseInt(strBetAmount); 
 //draw three cards (one card face up for dealer, two for player)
 
 //dealer first drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the dealer hand value & card, pulling index from array
 dealerHandValue = arrayCardValues[randomGenNum];
 //Check if the dealer got an ace
 if ((randomGenNum >= 2) && (randomGenNum <= 5))
 {
 dealerHandValue = dealerHandValue + 10;
 }
 int tempDealerHandValue = dealerHandValue;
 dealerCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 System.out.println("The dealer is showing a " + dealerCard);
 //System.out.println("The value is " + dealerHandValue);
 //dealers second drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the dealer hand value & card, pulling index from array
 dealerHandValue = arrayCardValues[randomGenNum];
 //Check if the dealer got an ace
 if ((dealerHandValue != 11) && (randomGenNum >= 2) && (randomGenNum <= 5))
 {
 dealerHandValue = dealerHandValue + 10;
 }
 dealerCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 //System.out.println("The dealers second card is " + dealerCard);
 //System.out.println("The dealers total hand value is: " + (tempDealerHandValue + dealerHandValue));
 
 
 
 //users first drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the user hand value & card, pulling index from array
 userHandValue = arrayCardValues[randomGenNum];
 //Check if the user got an ace
 if ((randomGenNum >= 2) && (randomGenNum <= 5))
 {
 userHandValue = userHandValue + 10;
 }
 int tempUserHandValue = userHandValue;
 userCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 System.out.println("Your first card is " + userCard);
 
 
 //users second drawn card
 randomGenNum = (int)((range * Math.random()) + 1)*2;
 //assigning the user hand value & card, pulling index from array
 userHandValue = arrayCardValues[randomGenNum];
 //Check if the user got an ace
 if ((userHandValue != 11) && (randomGenNum >= 2) && (randomGenNum <= 5))
 {
 userHandValue = userHandValue + 10;
 }
 userCard = arrayCardSuites[randomGenNum];
 //displaying values to the screen
 System.out.println("Your second card is " + userCard);
 System.out.println("Your total hand value is: " + (tempUserHandValue + userHandValue));
 
 }
 while (again == 1);
 
 }
PLEASE.I'M DESPERATE.
 
Can I also recommend the use of code tags for forum posts containing source code? Makes it all a bit more readable.
 
Not only would this be more appropriate in the Developers section It will also be helpful to them if you can give them the errors your getting. What are you using to compile with? Whats your system? Where are the Sources coming from. I'm sure these are just a few things the Dev's will need to know in order to help you. Good Luck to you.
 
I've moved this to the application development forum so you can get some better eyes on it.:)
 
Back
Top Bottom