java crew sign in..

Discussion in 'OT Technology' started by maxgohan, Jun 20, 2005.

  1. maxgohan

    maxgohan OT Supporter

    Joined:
    May 1, 2004
    Messages:
    8,742
    Likes Received:
    2
    Location:
    btown, toronto
    Code:
     public void whoWins ()
     	{
     		int xscore = 0;
     		int xcompscore = 0;
     		if (Score () == "Ace")
     		{
     			xscore = 1;
     		}
     		else if (Score () == "Jack")
     		{
     			xscore = 11;
     		}
     		else if (Score () == "Queen")
     		{
     			xscore = 12;
     		}
     		else if (Score () == "King")
     		{
     			xscore = 13;
     		}
     		else if (computerscore () == "Ace")
     		{
     			xcompscore = 1;
     		}
     		else if (computerscore () == "Jack")
     		{
     			xcompscore = 11;
     		}
     		else if (computerscore () == "Queen")
     		{
     			xcompscore = 12;
     		}
     		else if (computerscore () == "King")
     		{
     			xcompscore = 13;
     		}
     		else
     		{
     			xscore = Integer.parseInt (Score ());
     			xcompscore = Integer.parseInt (computerscore ());
     		}
     		total.setText (xscore + "blah" + xcompscore);
     	}
     
     public String computerscore ()
     	{
     		int x = (int) (Math.round (Math.random () * 12) + 1);
     		if (x == 1)
     		{
     			return "Ace";
     		}
     		if (x == 11)
     		{
     			return "Jack";
     		}
     		if (x == 12)
     		{
     			return "Queen";
     		}
     		if (x == 13)
     		{
     			return "King";
     		}
     		else
     		{
     			String jack = String.valueOf (x);
     			return jack;
     		}
     	}
     
     
     	public String Score ()
     	{
     		int totalScore = 0;
     		totalScore += hand [0].value;
     
     		if (totalScore == 1)
     		{
     			return "Ace";
     		}
     		if (totalScore == 11)
     		{
     			return "Jack";
     		}
     		if (totalScore == 12)
     		{
     			return "Queen";
     		}
     		if (totalScore == 13)
     		{
     			return "King";
     		}
     		else
     		{
     			String jack = String.valueOf (totalScore);
     			return jack;
     		}
     
     	}
     

    else
    {
    xscore = Integer.parseInt (Score ());
    xcompscore = Integer.parseInt (computerscore ());
    }

    that line doesnt work :s please help!
     
  2. maxgohan

    maxgohan OT Supporter

    Joined:
    May 1, 2004
    Messages:
    8,742
    Likes Received:
    2
    Location:
    btown, toronto
    nevermind got it to work :big grin:
     
  3. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    try to use a case statement, it would clean a lot of that up.

    Since case stataments are char[1] use J,Q,K,A. Just a suggestion
     

Share This Page