r/javahelp • • 6d ago

Unsolved Need Help with creating a functional map using java.

Hi. I'm currently doing a project where the general basis is building a functional automated warehouse. Where users may give the robots in the warehouse instructions.

The warehouse must have 3 robots several pick up and drop off points.

My current idea was creating a text based map something like this:

__________________________________________
|C 1 - - -                 2            A |
| ______ -                                |
|      | -                               E|
|      | -            C                   |
|______| -                                |
|T - - - -         S           3        D |
|_________________________________________|

Each Letter represents a zone for either Pick up or Drop off with Zone @ being unique for a unique Charging Station.

Numbers are the robots themselves.

| and _ walls. for the robot.

I'm currently unsure how to even draw up the map itself let alone get the things to move and interact.

If anyone has any resources for this I'd very much appreciate it.

Currently aware that It'd most likely be just printing the map over and over and over again but having it so that the Robot's themselves move as we're printing it along with a proper printing of the warehouse is eluding me.

__________________________________________
|C  - - -                 2            A |
| ______ -                                |
|      | 1                               E|
|      | -            C                   |
|______| -                                |
|T - - - -         S           3        D |
|_________________________________________|

edit: this is not a request to have the map done I'm mainly just asking if people have any specific resources.

Apologzies if there is some megathread I should be going to for questions like this.

3 Upvotes

10 comments sorted by

1

u/AutoModerator 6d ago
Moderator Announcement Read More »

2

u/gekigangerii 6d ago

Is this a homework assignment, does it ask to draw a map.

If so, seems like you have a 2D rectangular area, which is a good use case for a 2D array.

You can have a char[][] type array which are are rows and columns. You can populate them with letters for robots or walls or zones or empty space. And you can edit this array as a robot moves. And you can also turn it into a string for printing the map.

→ More replies (1)

1

u/vegan_antitheist 6d ago

Can't you just draw it in 2d and just show it on screen using awt? Doing this text based is just unnecessarily complicated.

1

u/EdenZer063 6d ago

Maybe. This is going to be the first time I'm doing anything properly fancy in terms of "graphics" so I thought doing something text based would be the simplest solution. My experience with Java is somewhat limited as well so Any real alternatives would also be appreciated.

→ More replies (3)

2

u/aqua_regis 6d ago

cough you have already drawn the map. Now think how a grid, like the grid you have drawn is represented in programming - it's a 2 dimensional array

Java is an OOP language, so, you could use OOP to represent your warehouse, your items, your drop-off points, your charging station, your robots, etc. Yet, for such a small assignment this is overkill. Just put the letters and numbers into your array.

There are, BTW, better formatting options than your lines (they make things a bit complicated). Look into the generally acknowledged Sokoban format and generally, Sokoban would be a good resource to help you getting started with your program.

1

u/BanaTibor 5d ago

You do not need a map, you just need the rules.
Like

  • the warehouse is 10 wide and 30 long.

  • Robot can not go through the pickup or dropoff points.

  • robot can not leave the are

  • certain area is off limit

and so on. Do not need to represent the warehouse "graphically" inside the code.