Jump to content

maze solver using stack or queue

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
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");

         }

    }

}




#2
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
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\LAUR...URA\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

#3
so1i

so1i

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 312 posts
You don't say what/where you're stuck. Are you looking for help with something? :)
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

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
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

#5
Mozana

Mozana

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
Apparently you guys are the only ones that find this project almost impossible so I understand




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users