Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Cow and Bulls Game Help (Urgent)

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cow and Bulls Game Help (Urgent)

    Disclaimer: I'm not asking anyone to do my homework, I just need a guiding hand so that I can finish it.

    So for my Java class I am to create a Cows and Bulls game. I am not able to use any String methods, Math.pow, Integer.parseInt, or Double.parseDouble. I am also to methods. Basically, how am I to go about doing the following:

    getDigit(int number, int i)-take a positive integer number and an index i as parameters and returns the ith digit (from right) of number. If number does not have ith digit, then it returns -1. This method must make call(s) to numDigits (I have this done already).
    A TA had mentioned doing something like this

    public static int getDigit(int number, int i){
     
    		for(int j = 0; j <= i-1; j++)
    		j = (number/10);
    		number = number%10;
    		return number;
    	}

    but when I try to call it into the main method I get this

    The method getDigit(int, int) in the type dsafhjsd is not applicable for the arguments
    (int)
    Sorry for it being such a long first post and I realize that many will be hesitant to help me, but any help would be appreciated.

    Thanks


    EDIT: If this is in the wrong section, would a mod please move it.
    EDIT II: I was able to get it


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Cow and Bulls Game Help (Urgent)

    I suggest posting an SSCCE showing us what you have so far. It sounds like you're calling the method incorrectly, but we can't be sure without looking at your code.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: Cow and Bulls Game Help (Urgent)

    From the error you're showing, that just means that you are giving the function the incorrect parameters. For instance if you are calling getDigit(5) that is incorrect. Your function declaration requires 2 ints. So it would be something like getDigit(234, 2). That's where i would start. This is why Kevin requested some complete, runable code. I'm just speculating what you did wrong as i cannot see your main function.

    --- Update ---

    Nevermind, just saw in initial post's edit that this has been solved. Please mark threads like this as [SOLVED].
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

Similar Threads

  1. Replies: 3
    Last Post: March 1st, 2013, 11:01 PM
  2. Simple game that requires me to load game settings from a file
    By 14fenix in forum Java Theory & Questions
    Replies: 5
    Last Post: December 1st, 2011, 09:21 PM
  3. Need urgent help regarding java word wrap function.. URGENT
    By coldice in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 16th, 2011, 05:43 AM