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 2 of 2

Thread: rock paper scissor. whats wrong here ??

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rock paper scissor. whats wrong here ??

    i have used do and while.
    but i dont now where my mistake is.
    please help.
    thanks

    public class Bladsteenschaar {
    	final int blad = 0;
        final int steen = 1;
        final int schaar = 2;
        int computer;
        int keuzeSpeler;
        String keuze;
     
        public void Maakjekeuze() {
    		keuze();
    		keuzeSpeler();
    		winnaar();
    	}
     
     
       	public void keuze() {
     
     
       		do {
        	System.out.println("Kies: blad, steen of schaar");
    		keuze = Input.readString().toLowerCase();
    		System.out.println("uw keuze is : " + keuze);
    		}
    		while ( !keuze.equals("blad") && !keuze.equals("steen") && !keuze.equals("schaar") );
     
    	}
     
    	public void keuzespeler() {
    		computer = (int) (Math.random() * 3);
     
    		if (keuze.equals("blad")) {
                keuzeSpeler = 0;
            }
            else if (keuze.equals("steen")) {
                    keuzeSpeler = 1;
            }
            else if (keuze.equals("schaar")) {
                    keuzeSpeler = 2;
         	}
     
    }
     
    	public void winnaar() {
     
    		switch (computer) {
    			case 0: //blad
    				switch (keuzeSpeler)
    				{
    					case 0: //blad
    						System.out.println("Speler koos " + keuze + ", De computer kiest : blad => Gelijkspel");
    						break;
    					case 1: //steen
    						System.out.println("Speler koos " + keuze + ", De computer kiest : blad => Computer wint");
    						break;
    					case 2: //schaar
    						System.out.println("Speler koos " + keuze + ", De computer kiest : blad => SPELER wint");
    						break;
    				}
    				break;
     
    			case 1: //steen
    				switch (keuzeSpeler)
    				{
    					case 0: //blad
    						System.out.println("Speler koos " + keuze + ", De computer kiest : steen => Speler wint");
    						break;
    					case 1: //steen
    						System.out.println("Speler koos " + keuze + ", De computer kiest : steen => Gelijkspel");
    						break;
    					case 2: //schaar
    						System.out.println("Speler koos " + keuze + ", De computer kiest : steen => Computer wint");
    						break;
    				}
    				break;
     
    			case 2: //schaar
    				switch (keuzeSpeler)
    				{
    					case 0: //blad
    						System.out.println("Speler koos " + keuze + ", De computer kiest : schaar => Computer wint");
    						break;
    					case 1: //steen
    						System.out.println("Speler koos " + keuze + ", De computer kiest : schaar => Speler wint");
    						break;
    					case 2: //schaar
    						System.out.println("Speler koos " + keuze + ", De computer kiest : schaar =>  Gelijkspel");
    						break;
    				}
    				break;
     
    			}
    		}
     
        public static void main(String[] args) {
            Bladsteenschaar bladsteenschaar = new Bladsteenschaar();
            bladsteenschaar.Maakjekeuze();
            bladsteenschaar.keuze();
            bladsteenschaar.keuzeSpeler();
            bladsteenschaar.winnaar();
     
        }
    }
    Last edited by JavaPF; November 10th, 2011 at 08:12 AM. Reason: Use highlight tags!


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: rock paper scissor. whats wrong here ??

    In future, make sure you use highlight tags when posting code.

    We need more information. What are your issues? What works and what doesn't?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. rock paper si
    By robingeldolf in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 4th, 2011, 06:41 AM
  2. Rock Paper Scissors Spock Lizard Player Problem
    By flyingcurry in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 3rd, 2011, 09:53 AM
  3. MyThesis: rock,paper,scissor..on mobile
    By Cross`17 in forum Java ME (Mobile Edition)
    Replies: 2
    Last Post: April 22nd, 2010, 08:33 AM
  4. whats wrong with this one....
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 6th, 2009, 10:08 AM
  5. [SOLVED] whats wrong with my IDE
    By chronoz13 in forum Java IDEs
    Replies: 2
    Last Post: August 27th, 2009, 06:34 AM