Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

maze solver using stack or queue

stack

  • Please log in to reply
4 replies to this topic

#1 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 22 April 2011 - 12:14 PM

I must create a maze solver using a queue then a Stack, our maze consists of four legael characters.
What i have done:
- read the maze from a txt file
- display it on a JPanel object
- created an enum (look below)
- class MyStack and MyQueue
- Implements agenda which specifies 5 methods

public enum Square
{
    start('o'),
    openSpace('.'),
    walls('#'),
    finish('*');
    private final Character symbol;
    Square(char sym)
    {
       symbol = sym;
    }

    @Override
    public String toString()
    {
        return this.symbol+"";
    }
    public static Square fromChar(char ch) throws IllegalArgumentException
    {
         switch(ch)
         {
             case '*':
                 return Square.finish;
             case '#':
                 return Square.walls;
             case 'o':
                 return Square.start;
             case '.':
                 return Square.openSpace;
             default :
                 throw new IllegalArgumentException("Invalid character");
         }
    }
}


  • 0

#2 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 22 April 2011 - 12:30 PM

and now i will post the agenda implemented by MyQueue and MyStack
public interface Agenda<T>
{
 boolean isEmpty();
 boolean add(T e);
 int size();
 boolean remove(T e);
 T peek();
}
http://C:\Users\LAURA\Desktop\SPG Final


so i must create an Agenda of locations to explore with the stack and queue and to get to the finish line while showing the blocks that I did explore or go through to het to the finish of the maze
  • 0

#3 so1i

so1i

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 297 posts

Posted 22 April 2011 - 01:28 PM

You don't say what/where you're stuck. Are you looking for help with something? :)
  • 0
My Company - My Homepage - My Twitter - My Google+ - My LinkedIn

"Things don’t have to change the world to be important.” - Steve Jobs

#4 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 22 April 2011 - 05:38 PM

yes I am looking for help implementing the stack so as to save the start location (o) , finish(*)\ and the spaces from start to finish, the same with the queue, hope u understand now
  • 0

#5 Mozana

Mozana

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 70 posts
  • Programming Language:Java, C#, PHP, JavaScript, PL/SQL
  • Learning:Objective-C

Posted 23 April 2011 - 12:09 PM

Apparently you guys are the only ones that find this project almost impossible so I understand
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download