
-----------------------------------
Tat
Wed Feb 04, 2004 9:34 pm

Text Based BlackJack(modified version of regular ones)
-----------------------------------
/*Tat Ho
YOU NEED TO GET THE ATTACHMENT KEYBOARDREADER TO WORK
Most stuff are based on my teacher's expectations including maximum cards = 3, betting twice and maybe more.  This was the hardest project i had to do since most ideas were from my brain(other projects we use teacher's outline including all the properties and methods in a class and classes and so on)
Sry if this game is non realistic but it meets all the requirements for my teacher's expectations
Opps almost forgot u need to save it as thBJMain.java
 *Black Jack Game*/
 
class thBJMain
{
	static BJGame game=new BJGame();
	
	public static void main(String args[])
	{
		game.play();
	}
}

class BJGame
{
	BJPlayer p1=new BJPlayer();
	BJPlayer p2=new BJPlayer();
	String playagain;
	String choice1, choice2;
	KeyboardReader reader=new KeyboardReader();
	
	void title()
	{
		System.out.println("Black Jack Game");
		reader.pause();
	}
	
	void play()
	{

		title();
		enterNames();
		while(p2.name.equals(p1.name))
		{
			p2.name=reader.readLine("Name was taken, please enter another one");
		}		
		do{
		p1.countbet=0;
		p2.countbet=0;
		p1.count=0;
		p2.count=0;
		p1.score=0;
		p2.score=0;
		p1.bet=0;
		p2.bet=0;
		p1.displayInfo();
		p2.displayInfo();
		enterBets();
		p1.getCard();
		System.out.println(p1.name + " card" + p1.count + "" + " is " + p1.hand);
		p1.getCard();
		System.out.println(p1.name + " card" + p1.count + "" + " is " + p1.hand);
		System.out.println(p1.name +"'s score:" + p1.score + "\n");
		p2.getCard();
		System.out.println(p2.name + " card" + p2.count + "" + " is " + p2.hand);
		p2.getCard();
		System.out.println(p2.name + " card" + p2.count + "" + " is " + p2.hand);
		System.out.println(p2.name +"'s score:" + p2.score + "\n");
		
		
		choice1=reader.readLine("Enter Hit or Stand " + p1.name+ " ");
		  choice1=choice1.toUpperCase();
		  while(!choice1.equals("HIT") && !choice1.equals("STAND"))
		  {
		  	choice1=reader.readLine("Invalid approach please enter Hit or Stand " + p1.name);
		  	choice1=choice1.toUpperCase();
		  }
		  if(choice1.equals("HIT")){
		  	p1.enterBet();
		  	p1.getCard();
		  	System.out.println(p1.name + " card" + p1.count + "" + " is " + p1.hand);
		  	System.out.println(p1.name +"'s score:" + p1.score);
		  	}else if(choice1.equals("STAND"))
		  		p1.enterBet();
		
		 
		choice2=reader.readLine("Enter hit or stand " + p2.name + " ");
		  choice2=choice2.toUpperCase();
		  while(!choice2.equals("HIT") && !choice2.equals("STAND"))
		  {
		  	choice2=reader.readLine("Invalid approach please enter Hit or Stand " + p2.name);
		  	choice2=choice1.toUpperCase();
		  }
		  if(choice2.equals("HIT")){
		  	p2.enterBet();
		  	p2.getCard();
		  	System.out.println(p2.name + " card" + p2.count + "" + " is " + p2.hand);
		  	System.out.println(p2.name +"'s score:" + p2.score);
		  	}else if(choice2.equals("STAND"))
		  		p2.enterBet();
		  		
		
		
		if(p1.score>21)
			p1.score=0;
			else if(p2.score>21)
				p2.score=0;
				
		if(p1.score>p2.score){
			System.out.println(p1.name + " wins with a score of " + p1.score + "\n");
			p1.money+=2*p1.countbet;
			p1.displayInfo();
			p2.displayInfo();
			}else if(p1.score