Results 1 to 12 of 12
  1. #1
    flyhigh is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default im have a string problem

    im not sure how to get hstring ,witch is a string to spell out (assets.picturename)
    in its place
    thanks all

    Java Code:
     for (int i=0;i<21;i++) 
        	{ 	
        		if  (holdyourhand[i]!=-1){
        			g.drawPixmap( Assets.(hstring), 128, 160);  
        		}
        		
            }

  2. #2
    flyhigh is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default Re: im have a string problem

    hey am i using string operator right?
    it should have put the word picstart in there ,i must be missing something


    Java Code:
    private void showhumandoms() {
            Graphics g = game.getGraphics();
            
            hstring="picstart";
           
           
            for (int i=0;i<21;i++) 
        	{ 	
        		if  (holdyourhand[i]!=-1){
        			g.drawPixmap(Assets. + hstring + , 128, 160);  
        		}
        		
            }
       
           
    
        	
        	
        	
        	   
        }

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,010
    Blog Entries
    7
    Rep Power
    20

    Default Re: im have a string problem

    Have you defined 'hstring' somewhere (in scope) so the compiler knows that you're talking about a String?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: im have a string problem

    What error(s) are you getting?
    Give the full text of them.
    Highlight the line(s) on which they occur as well.
    Please do not ask for code as refusal often offends.

  5. #5
    flyhigh is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default Re: im have a string problem

    in my main class i have this
    String hstring ;


    its line 10.
    assets are under lined and hstring are under lined.

    in post 2









    Multiple markers at this line
    - Syntax error on token ".", , expected
    - Assets cannot be resolved to a variable
    - Type mismatch: cannot convert from
    String to int
    - Syntax error on token "+", ++ expected

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: im have a string problem

    Since I can't find the drawPixMap method on the only Graphics class I know, I can only assume it takes String, int, int parameters?
    So that first thing needs to be a String.

    What do you want the String to look like?
    Please do not ask for code as refusal often offends.

  7. #7
    flyhigh is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default Re: im have a string problem

    picstart is a png image.
    i have domino images.
    it can be the first domino called up1.png ,so hstring="up1"; is all that would work.

    thanks

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: im have a string problem

    So, going back to Jos' post up there...where is hstring defined?
    Please do not ask for code as refusal often offends.

  9. #9
    flyhigh is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default Re: im have a string problem

    in this class




    Java Code:
    public class GameScreen extends Screen {
        enum GameState {
            Ready,
            Running,
            Paused,
            GameOver
            
        }
        
        GameState state = GameState.Ready;
        boolean runonce;
        boolean isthere;
        boolean skipit;
        String hstring ;
        String holdstring;
       
        
        int oldScoreH = 0;
        String scoreH = "0";
        
        int oldScoreC = 0;
        String scoreC = "0";
        
        int[][] playershand;
    	int[][] computerhand;
    	int[][] boneyard;
    	int holdyourhand[] = new int[21];
    	int holdcomputerhand[] = new int[21];
    	int holdbonepile[] = new int[14];
    	
    	final int BLANK = -1;// location empty

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: im have a string problem

    ...and is that the same class as the showhumandoms method above?
    And what is 'Asset' supposed to be?

    (This is getting very similar to trying to get blood from a stone).
    Please do not ask for code as refusal often offends.

  11. #11
    flyhigh is offline Member
    Join Date
    Oct 2012
    Posts
    13
    Rep Power
    0

    Default Re: im have a string problem

    im so sorry
    its bound to be simple ,im probly over looking something.
    thank you all for trying
    i need to go back and do alot of reading ,thanks

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: im have a string problem

    It is.
    When you post up code for a problem you are having, especially if it is just a few lines, then you need to explain what all the bits in there are. That is, any variables that are not declared in that snippet, and where they come from, and any classes that are non-standard. And also what, exactly, you are trying to do.

    In your case, if hstring is accessible at that point in the code then something like:
    Java Code:
    g.drawPixmap(hstring, 128, 160);
    would probably get it to compile.
    Whether it would work properly I do not know, as I do not know what values you require for drawPixMap...since I don't recognise it.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. Problem with <s:if> and string
    By SomeoneHere in forum Struts
    Replies: 1
    Last Post: 08-24-2012, 09:44 PM
  2. Having a problem with to String
    By thorobred in forum New To Java
    Replies: 20
    Last Post: 06-02-2012, 08:24 AM
  3. Replies: 6
    Last Post: 12-06-2010, 09:26 AM
  4. Problem with string tokenizer
    By twinytwo in forum AWT / Swing
    Replies: 2
    Last Post: 03-26-2009, 11:27 AM
  5. String Problem
    By gnomewise in forum New To Java
    Replies: 1
    Last Post: 10-19-2008, 12:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •