hey all im a relative noob with progaming if i could get some help i would be greatfull
this is homework but not the whole assignment thank you all

So when i run this it works fine if i type in the name of the first node but none of the other nodes?

playring is a doubly circular linked list

String name = input.next();

`public boolean playRingContains(String name){`
        boolean playRingContains=false;
        playRing.current=playRing.root;

        do{

            if(playRing.current.name.equals(name)){
                playRingContains=true;
                System.out.println("in check");
            }
            playRing.current=playRing.current.nextNode;
        }while(playRing.current!=playRing.root);
        return playRingContains;
    }

Edited 2 Years Ago by stephen.teacher: miss typed

further info that might help

I have a linked list with for nodes; nodes have a string name and gold amt.
in order the names are tom,lynn,jack,john. node names are passed in from a file then compared to a string typed in a consol widow.

I can't see any problems in that code. Are you certain that the nodes are being populated correctly with the names and links?

yes .... hhmmmm
i test both to see out put ie
System.out.println(playRing.current.name+name);
and shows that all nodes have there own name and that var name is containing the string passed in by scanner:
var nam = tom
Node : var name
prints
tom: tom
in check
lynn: tom
jack: tom

this works
but when i look for a the second name in the list it does not
tom:lynn
lynn:lynn
jack:lynn
not in check <prints if name was not found

in my code i run a test

System.out.println(playRing.current.name+name);
all nodes are populated withproper names and variable name is populated with prober scanner string i even trim scanner to make sure i am not takeing white space i ignore caps what i dont understand is why it works if i am checking the name on the firs node but not the othersie
tom:tom
lynn:tom
jack:tom
works
tom:lynn
lynn:lynn
jack:lynn
does not

if it is not in my contains method is can anyone tell me if they see a problem where i scan my values

public void methodGameManager(){
        System.out.print("Welcome to the Gold Hunt Manager");
        System.out.println("");
        System.out.println("What file name do you want to use for this game?");
        Scanner fileIn = new Scanner(System.in); 
        String nameOfFile;
        nameOfFile = fileIn.nextLine();


        try
        {
            fileIn = new Scanner(new File(nameOfFile));
            //input file must contain space between name and gold amount and space after gold amount no space after last gold amount

            fileIn.useDelimiter(" ");
            while(fileIn.hasNextLine())
            {
                String name = fileIn.next();
                String value = fileIn.next().trim();
                int goldAmt = Integer.parseInt(value.trim());
                playRing.addNodes(name,goldAmt);
            }
            fileIn.close();
        }
        catch(FileNotFoundException s)
        {
            System.out.println("File does Not Exist Please Try Again: ");
            methodGameManager();
        }

        do{

            //printPlayRing();
            //printBrig();
            if(!gameOver()){
                System.out.println("");
                System.out.println("game not over Who got captured?");
                Scanner caught=new Scanner(System.in);
                String check = caught.nextLine();
                if(playRingContains(check)){
                    System.out.println("playRing contains"+check);

                }
            }

        }while(playRing.root.nextNode!=playRing.root);

    }

you don't need to create a new instance of Scanner each time you read a value, that's just a waste of resources.

do{
            //printPlayRing();
            //printBrig();
            if(!gameOver()){
                System.out.println("");
                System.out.println("game not over Who got captured?");
                Scanner caught=new Scanner(System.in);
                String check = caught.nextLine();
                if(playRingContains(check)){
                    System.out.println("playRing contains"+check);
                }
            }
        }while(playRing.root.nextNode!=playRing.root);

I might be missing something here, but I don't see you actually changing either of those two variables, so either it never runs, or it'll be an infinite loop.

Alright guys i figuered it out when i use the the delimiter "" i am not counting for the "\n"so i ended up useing multiple dilimiters ie fileIn.useDelimiter(" |\n");

This question has already been answered. Start a new discussion instead.