Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Coloring map (https://www.askmehelpdesk.com/showthread.php?t=811711)

  • May 12, 2015, 12:28 PM
    Drei0614
    Coloring map
    I am doing the map program use stack. I set the color in the working stack as white(0), and other four colors in valid(1-4). However, when I run the program, it doesn't actually color the map. Could someone help to find my mistake?

    public void go(){
    Integer counter = 0;
    Integer backup = 0;
    while(!Working.empty()){
    // work on the item at the top of the working stack
    NodeInfo Current = Working.peek();

    // Insert this statement every time you change the color of a map node
    M.displayElement(Current.getName(), C[Current.getColor()], frame);

    if(Current.getColor()>4){ // out from rank, use color other than white, red, yellow, green and blue
    Current.setColor(0); // set color back to white
    Working.push(Valid.pop()); //push back from Valid to Working
    }
    else{
    Current.setColor(Current.getColor()+1); // set a new color if it doesn't run out rank 1-4
    Valid.push(Working.pop()); //push from Working to Valid
    }
    }
    /*Move items from one stack to the other with statements like
    *
    * Working.push(Valid.pop());
    * and
    * Valid.push(Working.pop());
    *
    */
    }

  • All times are GMT -7. The time now is 12:20 AM.