I am trying to set the boolean newEnergy to true only when the item is found. However, it is true at the beginning of the game and remains true until the command 'use' is used. Is there anyway to set newEnergy = true only when the item is found or taken?

        //Add Energy
        Item energy = new Item(" Double energy. \n" + "Type 'use' or 'consume' to use the energy. \n", "energy", 0);
        newEnergy = true;
        roomSix.addItem(energy);

Initialise it to false, then set it to true in the code where you find or take an item? Or is the problem actaually more complicated than that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.