Best Projects

Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)

DCSoft DOS Casino

Description: This is a simple CASINO program which rus in an MS-DOS window. It has games like Roulette, Black Jack,Bingo,and Poker. It will be updated frequently so please check for source code intermittently


//Balls
import java.util.*;

public class Balls
{
public static Random randnum = new Random(System.currentTimeMillis());
public static Vector bingoballs = new Vector(25);
private static int i;
private static int bingoNumber;
private static int mynum;
private static int sizeOfVector;
public static void initializeBingoVector()
{
for(i=0;i<=24;i++)
{
bingoballs.add(i);
}
}

public static int uniqueBingoNumber()
{
sizeOfVector = bingoballs.size();
mynum = randnum.nextInt(sizeOfVector);
bingoNumber = ((Integer)bingoballs.elementAt(mynum)).intValue();
bingoballs.removeElementAt(mynum);
return bingoNumber;
}

}




//Bingo
import java.util.*;
public class Bingo
{

public static int Board[ ][ ] = new int [5] [5]; // Naming two dimensional board.
public static Vector cards = new Vector (24); // Naming Vector of 24 items.
public static Random randnum = new Random(System.currentTimeMillis()); // Naming Random number function .
public static Game game = new Game();

public static int times = 0;
public boolean playagain;
public static double currentfunds;

public static void Bingo()
{




Board[2][2] = -1;

int tries = 1;
boolean win =false;
while(tries<=10 && win==false) // Recording the number of tries + wins.
{
int compnum = uniquerandom();
for (int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
if (Board[i][j] == compnum)
{
Board[i][j] = -1;

}




}
}
for( int i=0;i<5;i++)
{
if(Board[i][0]==-1&&Board[i][1]==-1&&Board[i][2]==-1&&Board[i][3]==-1&&Board[i][4]== -1)
{

win = true;

}
}
for(int i=0;i<5;i++)
{
if(Board[0][i]==-1&&Board[1][i]==-1&&Board[2][i]==-1&&Board[3][i]==-1&&Board[4][i]==-1)
{
win = true;
}
}
if(Board[0][0]==-1&&Board[1][1]==-1&&Board[2][2]==-1&&Board[3][3]==-1&&Board[4][4]==-1)
{
win = true;
}
if(Board[0][4]==-1&&Board[1][3]==-1&&Board[2][2]==-1&&Board[3][1]==-1&&Board[4][0]==-1)
{
win = true;
}
System.out.println(" ");
printarray();
if(win == true)
{
System.out.println("Bingo\n Well done. You have just WON!!! \n");
currentfunds = currentfunds;
game.updatefunds(currentfunds);
}

tries += 1; // Increases tries by 1.
}
if(win == false)
{
currentfunds = 0-currentfunds;
System.out.println("You did not have a win");
game.updatefunds(currentfunds);

}
}

public static void printarray()
{


int i;
int j;
for(i=0; i<5;i++)
{
for (j=0; j<5;j++)
{

if(Board[i][j]== -1) // prints X in place of -1
{
System.out.print(" "+"X");
System.out.print(" "); // Makes equal spacing.
}
else
{
if(Board[i][j]<10)
{
System.out.print(" "+Board[i][j]);
System.out.print(" ");
}
else
{
System.out.print(Board[i][j]);
System.out.print(" ");
}
}
}
System.out.println("");
}
}
public static int uniquerandom() // to get a unique random number from vector.
{
int returnValue;
int myNum;
myNum= randnum.nextInt(cards.size());
returnValue=((Integer)cards.elementAt(myNum)).intValue();
cards.removeElementAt(myNum);
return returnValue;


}


public static void initializearray() // to initialize the array.
{
int i;
int j;
if(times == 0)
{
currentfunds = game.funds();
}
else
{
currentfunds = game.updatedfunds();
currentfunds = game.newBet();

}


for(i=0; i<5;i++)
{
for(j=0;j<5;j++)
{


Board[i][j] = uniquerandom();
if(Board[i][j]<10)
{
System.out.print(" "+Board[i][j]);
System.out.print(" ");
}
else
{
System.out.print(Board[i][j]);
System.out.print(" ");
}
}
System.out.println(" ");
}

}


public static void initvector(int numofelements) // to initialize the vector
{

cards = new Vector();
int i;
for (i=0; i<=numofelements;i++)
{
cards.add(i);

}
}
public void play()
{
System.out.println("B I N G O");
do
{
initvector(24);
initializearray();
initvector(24);
Bingo();
Game game = new Game();
playagain = game.play();
times += 1;
}while(playagain==true);
}

}

// End of Bingo Function





//Blackjack.java
import java.util.*;

public class Blackjack
{

public static int i;
private static int decksize; //holds the size of both player and computer decks
private static int sum; // holds the final sum of the player's hand
private static int compsum; //holds the final sum of the computer's hand
private static int temp; //a temporary variable that is added to user's sum
private static int additiontest; //a test to determine if the users number is over 21
private static int compadditiontest; // a test to ensure computer is not over 17
private static int comptemp; //a temporary variable that is added to computer's sum
private static boolean sumboolean; //returns true if user's sum is not over 21
private static boolean compsumboolean; //returns true if compute's sum is not over 21
private static boolean playagain; //the returns true if user wants to play again
public static Carddeck deck = new Carddeck();
public static Hand player = new Hand(deck,0);
public static Hand computer = new Hand(deck,0); //a new hand
public static Prompt userprompt = new Prompt(); //prompt class
public static Game game = new Game(); //the game class
public static int userchoice; //holds whether users want to perform a hit me or a stand
public static double currentfunds; //this is self explanatory
public static int times = 0; //the number of times the users play the game

public static void blackjack()
{

if(times==0)
{
currentfunds = game.funds();
}
else
{
currentfunds = game.updatedfunds();
currentfunds = game.newBet();
}

computer.add();
computer.add();

System.out.println(" ");

System.out.print("Your cards are: " );

player.add();
player.add();
decksize = player.sizeOfHand();
for(i=0;i {

player.print(i);

}
System.out.println("\n ");
System.out.print("The computer's visible card is: ");
computer.print(1);
System.out.println(" ");
addplayercards();
while(sumboolean==true)
{
System.out.println("Would you like to\n1. Hit me\n2. Stand");
userchoice = userprompt.integerInput();
if(userchoice==1)
{

player.add();
System.out.print("Your current cards are: ");
decksize = player.sizeOfHand();
for(i=0;i {
player.print(i);
}
System.out.println(" ");
addplayercards();

}
else if(userchoice==2)
{
sumboolean = false;
}
else
{
System.out.println("This choice is not in the list");
}
}


addcomputercards();

while(compsumboolean==true)
{
computer.add();
addcomputercards();
}
decksize = computer.sizeOfHand();
System.out.println("The final computer cards were: ");
for(i=0;i {

computer.print(i);
}
System.out.println(" ");
wins();



}

public static void wins()
{
System.out.println("The sum of the Computer's card is: "+compsum);
if(compsum>sum && compsum<=21)
{
System.out.println("The computer wins this game");
currentfunds = 0 - currentfunds;
}
else if(compsum {
System.out.println("Congratulations!!!\nYou have just won this round");
currentfunds = currentfunds;
}
else if(sum>21)
{
System.out.println("You busted, therefore you just lost the game");
currentfunds = 0- currentfunds;
}
else if(compsum>21 && sum<=21)
{
System.out.println("You won this round of the game");
currentfunds = currentfunds;
}
else if(sum==compsum && sum<=21 && compsum<=21)
{
System.out.println ("You tie, therefore the computer wins the game");
currentfunds = 0 - currentfunds;
}

game.updatefunds(currentfunds);

}


public static void addplayercards()
{

decksize = player.sizeOfHand();
sum = 0;

for(i=0;i {
temp = player.getValue(i) ;
if(temp==1)
{
additiontest = sum + 11;
if(additiontest<=21)
{
temp = 11;
}
}
sum = sum + temp;
}
System.out.println("The sum of your cards is "+sum);
if(sum<21)
{
sumboolean = true;
}
else
{
sumboolean = false;
}

}

public static void addcomputercards()
{
decksize = computer.sizeOfHand();
compsum =0;
for(i=0;i {
comptemp = computer.getValue(i);

if(comptemp==1)
{
compadditiontest = sum + 11;
if(compadditiontest<=21)
{
comptemp = 11;

}
}
compsum = compsum + comptemp;
}
if(compsum<17)
{
compsumboolean = true;
}
else
{
compsumboolean = false;
}
}

public static void play() //this is called in the casino main
{
System.out.println("B L A C K J A C K");
do
{
blackjack();
player.removeAllElements();
computer.removeAllElements();
Game game = new Game();
playagain = game.play();
times += 1;
}while(playagain==true);


}


}




//Card
import java.util.*;

public class Card
{
public int ID; // holds the index number of the cards
private Carddeck deck;
public int pokervalue;
public int value; // holds the true value of the cards
public String face; // the face of the cards Ace to King
public String suit; // the suit of the cards
public String Faces[ ] = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}; //the face value array
public String Suit[ ]= {"D", "S", "C", "H"}; //the suit array
public int Value[ ]={1,2,3,4,5,6,7,8,9,10,10,10,10}; //the value of the cards
public int pokerValue[ ] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; //the special value of poker cards


public Card(int newID)
{
ID = newID;
face = Faces[ID%13];
suit = Suit[(int)(ID/13)];
value = Value[ID%13];
pokervalue = pokerValue[ID%13];
}

public void print(Card newCard)
{
Card myCard;
myCard = newCard;
System.out.print(face + suit+" ");
// System.out.print();//first of all get the index number.
}



public int cardValue(int newID) //this function is dependent on the face of the card therefore face must be called before it.
{
ID = newID;
int test;
test = ID%13;
value = Value[test];
return value;
}





}




//CardDeck.java
import java.util.*;

public class Carddeck
{
public static Vector carddeck = new Vector(52);
public static Random randnum = new Random(System.currentTimeMillis());
public static Card Card;

public static int i;


public static void deckinitialize()
{
int decksize = carddeck.size();
for(i=0;i<=51;i++)
{
carddeck.add(new Card(i));
Card = ((Card)(carddeck.elementAt(i)));

}



}
public static Card uniqueCard()
{
int index;
Card element;
index = randnum.nextInt(carddeck.size());
element = ((Card)(carddeck.elementAt(index)));
carddeck.removeElementAt(index);
return element;

}

}




//Casino
/**
* OKOYE CHUKA DANIEL
*
* CASINO GAME IN OBJECT ORIENTED PROGRAMMING STYLE
*
*4TH OF JANUARY 2006
*
*VERSION 2.1.1
*
*/
import java.util.*;

public class CASINO
{


public static void main (String[] args)
{
Integer gameoption; //holds the user's choice of games
gameoption=0;


while(gameoption != 6)

{


System.out.println(" Welcome to Hello World ASCII Casino\n\n A Casino of Hope and Possiblities\n\n Choose from the menu below to start a game\n 1. Poker\n 2. Black Jack\n 3. Roulette\n 4. Bingo\n 5. Higher Lower\n 6. Quit" );





Prompt userPrompt = new Prompt();
gameoption = userPrompt.integerInput();

if (gameoption==1) // Begin Poker
{
Poker pokerGame = new Poker();
pokerGame.play();
System.out.println("Thank you for playing Poker\n");
} // End Poker

if (gameoption==2) // Begin BlackJack
{

Blackjack blackjackGame = new Blackjack();
blackjackGame.play();
System.out.println("Thank you for playing Black Jack\n");
}// End BlackJack
if (gameoption==3) // Begin Roulette
{
Roulette rouletteGame = new Roulette();
rouletteGame.play();
System.out.println("Thank you for playing Roulette\n");
}//end Roulette

if (gameoption==4) // Begin Bingo
{
Bingo bingoGame = new Bingo();
bingoGame.play();
System.out.println("Thank you for playing Bingo\n");
}// end Bingo

if (gameoption==5) // begin Higher Lower
{
Higherlower hiLoGame = new Higherlower();
hiLoGame.play();
System.out.println("Thank you for playing Higher Lower\n");
}//end higher lower


}
System.out.println("Thank you for playing Hello World Casino.\nBye");
}

}



//game
import java.util.*;

public class Game
{
public boolean playagain; //the play again boolean
public static boolean goodbet; //makes sure user does not enter a number greater than the amount available for bet
public int gameoption; //holds wether user wants to play again or not
public int wrongnumber = 1;//prevents the user from entering the wrong number not on the list.
public static double Funds; //holds the users money
public static double betamount;
public static double returnedfunds;//the amount returned from the games
public boolean play()
{
while(wrongnumber==1)
{
System.out.println("Would you like to play again\n 1. Yes\n 2. No ");
Prompt userPrompt = new Prompt();
gameoption = userPrompt.integerInput();
if(gameoption==1)
{
playagain=true;
wrongnumber = 0;

}
else if(gameoption==2)
{
playagain=false;
wrongnumber = 0;
}
}
return playagain;
}

public static double funds()
{
Funds = 10000;
System.out.println("You have $" +Funds);
System.out.println("How much would you like to bet: ");
Prompt userPrompt = new Prompt();

goodbet = true;

while(goodbet == true)
{
System.out.print("$");


betamount = userPrompt.integerInput();
if(betamount<=Funds && betamount>0)
{
System.out.println("You have chosen to bet $" + betamount);
goodbet = false;

}
else if(betamount>Funds || betamount<0)
{
System.out.println("You dont have this amount of money. Enter a new bet");
goodbet = true;

}


}
System.out.println("You do not have any more money to bet");
return betamount;

}

public static void updatefunds(double newfunds)
{
returnedfunds = newfunds;

Funds = Funds + returnedfunds;

System.out.println("You current funds is now $" +Funds);
if(Funds<=0)
{
System.out.println("You have run out of funds.\nThank you for playing Hello World Casino.\nBye");
System.exit(0);
}
}

public static double updatedfunds()
{
return Funds;
}

public static double newBet() // this is for the user to place a new bet after the first one
{


System.out.println("You have $" +Funds);
System.out.println("How much would you like to bet: ");
Prompt userPrompt = new Prompt();

goodbet = true;

while(goodbet == true)
{
System.out.print("$");


betamount = userPrompt.integerInput();
if(betamount<=Funds && betamount>0)
{
System.out.println("You have chosen to bet $" + betamount);
goodbet = false;

}
else if(betamount>Funds && Funds>0)
{
System.out.println("You dont have this amount of money. Enter a new bet");
goodbet = true;

}

else
{
System.out.println("You do not have any more money to bet");
goodbet = false;
}

}


return betamount;

}
}




//Hand.java
import java.util.*;

public class Hand
{
public Carddeck deck; //all it says is u are expecting a variable of type carddeck.
public Card card;
public int i;
public int j;
public int handSize; //holds the size of the vector player vector
public int decksize; //holds the size of the vector also
public int myCard; //holds cards got from the card deck
public Card temp; //a temporary variable for cards

public Vector cardHand = new Vector();
public Hand(Carddeck newdeck,int numberOfCards) //for the intial issuance of cards to both players.the newdeck just points to the same vector called deck.
{
deck.deckinitialize();
deck = newdeck;
for(i=0;i {
cardHand.add(deck.uniqueCard());
}


}

public void add()//for the hit me
{

cardHand.add(deck.uniqueCard());
}
public void print(int newID)
{
int myCard;
myCard = newID;
card = ((Card)(cardHand.elementAt(myCard)));
card.print(card);

}

public int sizeOfHand()
{
handSize = cardHand.size();
return handSize;
}


public int getValue(int positionOfCard) // this is wrong bcos u have to search for the card that matches the user own in the orginal deck then submit the value.
{
int cardIndex;
int cardID;
int cardValue;
Card cardProp;
cardIndex = positionOfCard;
cardProp = ((Card)(cardHand.elementAt(cardIndex)));
cardID = cardProp.ID;
card = cardProp;
cardValue=card.value; //giving the cardValue function in card the id to get value of card.
return cardValue;

}

public void removeAllElements()
{
cardHand.clear();
}

public void setHand(int newposition)
{
int cardIndex;
cardIndex = newposition;
temp = deck.uniqueCard();
cardHand.set(cardIndex, temp);

}

public void sort()
{
decksize = cardHand.size();
for(j=decksize -1 ; j>=0; j--)
{
for( i=0; i {

int value1;
int value2;
Card temp = (Card)cardHand.elementAt(i);
card = temp;
value1 = card.pokervalue;
temp = (Card)cardHand.elementAt(i+1);
card = temp;
value2 = card.pokervalue;
if(value1 > value2)
{

temp = (Card)(cardHand.elementAt(i));
cardHand.set(i, (Card)cardHand.elementAt(i+1));
cardHand.set(i+1,temp);
}
}
}
}

public int pokervalue(int positionOfCard)
{
int cardIndex;
int cardID;
int cardValue;
Card cardProp;
cardIndex = positionOfCard;
cardProp = ((Card)(cardHand.elementAt(cardIndex)));
cardID = cardProp.ID;
card = cardProp;
cardValue=card.pokervalue; //giving the cardValue function in card the id to get value of card.
return cardValue;
}

public String pokerface(int positionOfCard)
{
int cardIndex;
String cardface;
Card cardProp;
cardIndex = positionOfCard;
cardProp = ((Card)(cardHand.elementAt(cardIndex)));
card = cardProp;
cardface =card.face; //giving the cardValue function in card the id to get value of card.
return cardface;
}


}



//HigherLower
import java.util.*;


public class Higherlower
{
public Game game = new Game();

private boolean playagain;
public int x; // this holds the random number
public int userguess; //holds the guesses of the user
public double currentfunds;
public static int times = 0 ; // this is to make sure the funds does not re initialize

public void higherlower()
{


Random mynum = new Random();
x = mynum.nextInt(50); // assigning the random number to x.
int right;
int counter;
right = 0;
System.out.println("H I G H E R L O W E R");

if(times == 0)
{
currentfunds = game.funds();
}
else
{

currentfunds = game.updatedfunds();
currentfunds = game.newBet();
}
System.out.println("Note: You have only 5 trials\nThe number chosen by the computer is X\n Enter a number from 1-50");

for(counter=0;counter<=4;counter++)
{

System.out.println("");
System.out.println("Please enter your guess");

Prompt userPrompt = new Prompt();
userguess = userPrompt.integerInput();

if(userguess==x)
{
System.out.println("You have guessed the right number");
currentfunds = currentfunds ;
game.updatefunds(currentfunds);
counter = 5;
}

if(userguess>x)
{
System.out.println("Wrong Guess.");
System.out.println("");
System.out.println("Go Lower");
}

if(userguess {
System.out.println("Wrong Guess.");
System.out.println("");
System.out.println("Go Higher");
}



}
if(userguess!=x)
{
currentfunds = 0 - currentfunds;
game.updatefunds(currentfunds);
}


}


public void play()
{

do
{
higherlower();
Game game = new Game();
playagain = game.play();
times = times +1;
}while(playagain==true);

}

}






//Poker.java
import java.util.*;

public class Poker
{
public static Carddeck deck = new Carddeck();
public static Hand player = new Hand(deck,0);
public static Prompt prompt = new Prompt();
public static Game game = new Game();


public static int i;
public static int decksize; // hods the user's decksize
public static int exchangeCards; // holds the number of cards the user wants to exchange.
public static int menuErrorProof; // ensures that the user puts in the approriate number from the menu list.
public static int cardnos; //holds the position of the card the user wants to change
public static boolean goodInput; //this checks to make sure the user does not put a card position number above 5
public static boolean wins; //checks if there is any wins for the user
public static boolean playagain; //self explanatory
public static double currentfunds; //self explanatory
public static int times = 0; //the number of times the user plays the game

public static void poker()
{
if(times==0)
{
currentfunds = game.funds();
}
else
{
currentfunds = game.updatedfunds();
currentfunds = game.newBet();
}

for(i=0;i<5;i++)
{
player.add();
}
System.out.println("Your cards are: ");

decksize = player.sizeOfHand();
for(i=0;i {
player.print(i);
}
System.out.println("");
goodInput = false;
while(goodInput==false)
{
System.out.println("Do you want to exchange any of your cards ?\n1. Yes, 1 card\n2. Yes, 2 cards\n3. Yes, 3 cards\n4. Yes, 4 cards\n5. Yes, 5 cards\n6. None ");



exchangeCards = prompt.integerInput();
menuError();
}
if(exchangeCards != 6)
{

for(i=1; i<=exchangeCards; i++)
{
goodInput = false;
while(goodInput==false)
{
System.out.println("What is the card number position you want to exchange ?" );
cardnos = prompt.integerInput();
cardnos = cardnos - 1;
arrayOutOfBounds();
}
player.setHand(cardnos);
System.out.println("The card has been exchanged");

}


}


wins();

}

public static boolean arrayOutOfBounds()
{

decksize = player.sizeOfHand();
decksize = decksize-1;
goodInput = false;


if(decksize>=cardnos && decksize>=0)
{
goodInput = true;
}
else
{
System.out.println("Your card hand is not that large. \nEnter a new number from 1 to 5.");
goodInput = false;
}
return goodInput;
}

public static boolean menuError()
{
menuErrorProof = exchangeCards;
if(menuErrorProof<=6 && menuErrorProof>=1)
{
goodInput = true;
}
else
{
goodInput = false;
System.out.println("This option is not on the list");
}
return goodInput;
}

public static void wins()
{
player.sort();
System.out.println("Your sorted cards are: ");
decksize = player.sizeOfHand();
for(i=0;i {
player.print(i);
}
System.out.println("");
wins = false;
while(wins == false)
{

// Royal flush code
if((player.pokervalue(0)==1)&&(player.pokervalue(1)==10)&&(player.pokervalue(2)==11)&&(player.pokervalue(3)==12)&&(player.pokervalue(4)==13)&&(player.pokerface(0)==player.pokerface(1)) && (player.pokerface(1)==player.pokerface(2)) && (player.pokerface(2)==player.pokerface(3)) && (player.pokerface(3)==player.pokerface(4)))
{
wins = true;
System.out.println("Wow!!, you have just got a royal flush");
currentfunds = currentfunds * 10;

}
// Straight flush code
else if((player.pokervalue(0)==(player.pokervalue(1)-1)) && (player.pokervalue(1)==(player.pokervalue(2)-1)) && (player.pokervalue(2)==(player.pokervalue(3)-1)) && (player.pokervalue(3)==(player.pokervalue(4)-1)) && (player.pokerface(0)==player.pokerface(1)) && (player.pokerface(1)==player.pokerface(2)) && (player.pokerface(2)==player.pokerface(3)) && (player.pokerface(3)==player.pokerface(4)))
{
wins = true;
System.out.println("Congratulations, you got a Straight flush");
currentfunds = currentfunds * 5;
}

// 4 of a kind code
else if((player.pokervalue(0) == player.pokervalue(1)) && (player.pokervalue(1)==player.pokervalue(2))&&player.pokervalue(2)==player.pokervalue(3) || (player.pokervalue(1) == player.pokervalue(2)) && (player.pokervalue(2)==player.pokervalue(3)&&player.pokervalue(3)==player.pokervalue(4)))
{
wins = true;
System.out.println("Congrats, you have just got a 4 of a kind");
currentfunds = currentfunds * 4.5;
}

// full house code
else if((player.pokervalue(0)==player.pokervalue(1))&&(player.pokervalue(2)==player.pokervalue(3))&&(player.pokervalue(3)==player.pokervalue(4))||(player.pokervalue(0)==player.pokervalue(1))&&(player.pokervalue(1)==player.pokervalue(2))&&(player.pokervalue(3)==player.pokervalue(4)))
{
wins = true;
System.out.println("You have a full house");
currentfunds = currentfunds * 4;
}

// flush code
else if((player.pokerface(0)==player.pokerface(1)) && (player.pokerface(1)==player.pokerface(2)) && (player.pokerface(2)==player.pokerface(3)) && (player.pokerface(3)==player.pokerface(4)))
{
wins = true;
System.out.println("You have a Flush");
currentfunds = currentfunds * 3.5;
}

//a straight code
else if((player.pokervalue(0)==(player.pokervalue(1)-1)) && (player.pokervalue(1)==(player.pokervalue(2)-1)) && (player.pokervalue(2)==(player.pokervalue(3)-1)) && (player.pokervalue(3)==(player.pokervalue(4)-1)) || (player.pokervalue(0)==1)&& (player.pokervalue(1)==(player.pokervalue(2)-1)) && (player.pokervalue(2)==(player.pokervalue(3)-1)) && (player.pokervalue(3)==(player.pokervalue(4)-1)))
{
wins = true;
System.out.println("You have a Straight");
currentfunds = currentfunds * 3;
}

//three of a kind code
else if((player.pokervalue(0)==player.pokervalue(1))&&(player.pokervalue(1)==player.pokervalue(2)) || (player.pokervalue(1)==player.pokervalue(2))&&(player.pokervalue(2)==player.pokervalue(3)) || (player.pokervalue(2)==player.pokervalue(3))&&(player.pokervalue(3)==player.pokervalue(4)))
{
wins = true;
System.out.println("You have 3 of a Kind");
currentfunds = currentfunds * 2.5;
}
//two pair code
else if ((player.pokervalue(0)==player.pokervalue(1)) && (player.pokervalue(2)==player.pokervalue(3)) || (player.pokervalue(0)==player.pokervalue(1)) && (player.pokervalue(3)==player.pokervalue(4))|| (player.pokervalue(1)==player.pokervalue(2)&&player.pokervalue(3)==player.pokervalue(4)))
{
wins = true;
System.out.println("You have Two Pair");
currentfunds = currentfunds * 2;
}

//a pair code
else if((player.pokervalue(0)==player.pokervalue(1)) || (player.pokervalue(1)==player.pokervalue(2)) || (player.pokervalue(2)==player.pokervalue(3)) || (player.pokervalue(3)==player.pokervalue(4)))
{
wins = true;
System.out.println("You have a Pair");
currentfunds = currentfunds * 1.5 ;
}
else
{
System.out.println("Your cards evaluate to nothing.");
currentfunds = 0 - currentfunds;
wins = true;
}

game.updatefunds(currentfunds);
}


}


public static void play()
{
do
{

poker();
player.removeAllElements();
Game game = new Game();
playagain = game.play();
times += 1;
}while(playagain==true);
}
}




//Prompt.java
import java.util.*;


public class Prompt
{
public static Scanner input = new Scanner(System.in);
public static boolean exit;
public static int gameoption;
public static int integerInput()
{

exit = false;

while(exit!=true)
{
if(input.hasNextInt())
{
gameoption = input.nextInt();
exit = true;
input = new Scanner(System.in);

}
else
{
System.out.println("Please put in a valid Integer");
input = new Scanner(System.in);
}
}
return gameoption;
}

}





//Roulette.java
import java.util.*;
public class Roulette
{
public static Random randnum = new Random(System.currentTimeMillis());
public static Game game = new Game();

public static int betChoice; // holds the number users choose during bets.
public static String numtype; // holds wether number is even or odd.
public static int numberCode; // test condition for number bets
public static int evenOddCode; // test condition for even odd bets
public static boolean playagain; // the play again boolean.
public static int times = 0;
public static double currentfunds;



public static void roulettegame()
{

if(times == 0)
{
currentfunds = game.funds();

}
else
{
currentfunds = game.updatedfunds();
currentfunds = game.newBet();
}
int menuChoice;
System.out.println("Choose From the Options Below to place a Bet or Roll Wheel");
System.out.println("1. Number\n2. Even or Odd");
System.out.println("3. Roll Wheel. ");

/* menuChoice1 = number
* menuChoice2 = Even or Odd
* menuChoice3 = RollWheel
*/

int goodInput = 1;
while(goodInput== 1)
{
Prompt userPrompt = new Prompt(); //the prompt class

menuChoice = userPrompt.integerInput();
if (menuChoice==1)
{
numberCode = 1; // makes the computer do a comparison
numberChoice1();
System.out.println("Choose From the Options above to place a Bet or Roll Wheel");
}
if (menuChoice==2)
{
evenOddCode = 1;
numberChoice2();
System.out.println("Choose From the Options above to place a Bet or Roll Wheel");
}

if(menuChoice==3)
{
numberChoice3();
goodInput = 0;

}




}// end of while loop.
}

public static void numberChoice1() //to place a bet on a number
{
System.out.println("Please choose a number between 0 and 28 to place bet on");
int loop=0;
while(loop!=1)
{
Prompt userPrompt = new Prompt();
betChoice= userPrompt.integerInput();
if (betChoice<29 && betChoice>=0)
{
System.out.println("Your bet is currently placed on " + betChoice);
loop = 1;
}
else
{
System.out.println("This number is not in the range specified");
System.out.println("Enter a new number to place bet on");
}



} // end of while loop.
} //place bet on number



public static void numberChoice2() //to place a bet on number type(even or odd)
{

int overtest = 0;
while(overtest !=1 )
{
System.out.println("Choose which number type to place bet on\n1. Even\n2. Odd");
int number;

Prompt userPrompt = new Prompt();
number = userPrompt.integerInput();
int test = 0;
while (test !=1) // prevents the player from selecting a wrong number not on the list.
{

if(number == 1)
{
System.out.println("You placed your bet on an even number");
test =1;
overtest =1;
numtype="even";
}
if(number==2)
{
System.out.println("You place your bet on an odd number");
test =1;
overtest = 1;
numtype="odd";
}
if(number!=1&&number!=2)
{
System.out.println("You did not choose a number type sucker");
test =1;
}
}


} // end of first while loop
} //end of place bet on even or odd function


public static void numberChoice3() //for the user to spin the wheel
{

int wheelnum = randnum.nextInt(28);// spins the wheel.
int test;
test = wheelnum%2;

/*the following code below is to evaluate all the possible win conditions*/

if(test==0)// beginning of even mod
{
if(numtype=="even") // converting numtype to a number for program to evaluate.
{
System.out.println("The ball stopped at " +wheelnum);
System.out.println("Your even number guess was right");
currentfunds = currentfunds;


}
if(numtype=="odd")
{
System.out.println("The ball stopped at " +wheelnum);
System.out.println("Your odd number guess was wrong");
currentfunds = 0 - currentfunds;

}

}// end even mod
if(test==1) // beginning of odd mod
{
if(numtype=="odd")
{
System.out.println("The ball stopped at " +wheelnum);
System.out.println("Your odd number guess was right");
currentfunds = currentfunds;

}
if(numtype=="even")
{
System.out.println("The ball stopped at " +wheelnum);
System.out.println("You even number guess was wrong");
currentfunds = 0 - currentfunds;

}
} // end of odd mod.

if(numberCode==1 && betChoice==wheelnum)
{
System.out.println("The ball stopped at " +wheelnum);
System.out.println("Its your lucky day.\n\n You have just won the game");
currentfunds = currentfunds * 1.5;

}
if(numberCode==1 && betChoice!=wheelnum)
{
System.out.println("The ball stopped at " +wheelnum);
System.out.println("Hey, you placed your bet on the wrong number, loser.");
currentfunds = 0- currentfunds;

}
if(evenOddCode!= 1 && numberCode!= 1)
{
System.out.println("Scared of placing bets ?\nYou chose to roll the wheel without placing any bets.\nThe ball stopped at "+wheelnum);
currentfunds = 0;
}


currentfunds = currentfunds;


game.updatefunds(currentfunds);


} //roll wheel.

public static void play() //this function is called from the casino main.
{
System.out.println("R O U L E T T E");
do
{
roulettegame();
numtype = "";
betChoice = 0;
Game game = new Game();
playagain = game.play();
times = times +1;
}while(playagain==true);
}


}



No comments: