Thread: Java help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    12
    Rep Power
    0

    Java help


    I wrote main class for edgematch in java.
    I need to check the solution for edgematch to see if it is valid. I compiled the code but it shows grid already filled.

    here is my code:


    Code:
    /**
     *
     * @author usmanm2
     */
    public class Main {
    
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            
            int rows = 6;
            int columns = 6;
            int colours = 7;
    
            EdgeMatch em = new EdgeMatch(rows, columns, colours);
            em.randomYesInstance();
            
            EdgeMatchSolution ems = new EdgeMatchSolution(em);
            ems.randomSolution();
                          
            EdgeMatchDisplay emd = new EdgeMatchDisplay(ems, 500, 500);
            emd.setVisible(true);
            boolean answer = CheckSolution(ems, rows, columns);
        }
        
        public static boolean CheckSolution(EdgeMatchSolution ems, int rows, int columns)
        {
            
            for (int i = 0; i <rows; i++)
                for (int j = 0; j <columns; j++)
                {
                    if (ems.occupied(i,j))
                        return false;
                }
                return true;
        }
    }
    regarding the second part for checksolution method is to check the solution but my program shows something else.
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Please edit your post and wrap the code in code tags.
    Where is the CovUni package defined? The code can't be tested without it.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    12
    Rep Power
    0
    this thread belong to different tasks.
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    this thread belong to different tasks.
    Can you make one thread that contains all the parts for your question?

IMN logo majestic logo threadwatch logo seochat tools logo