Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:29:00+00:00 2026-05-28T15:29:00+00:00

I am making a program using the LRV(Least recently visited) Algorithm. Basically, I design

  • 0

I am making a program using the LRV(Least recently visited) Algorithm.
Basically, I design the algorithm for a robot to traverse through a grid (which is a 2D char array). The robot whilst traversing the grid checks whether each cell is either EMPTY (defined by ‘-‘), OCCUPIED ( defined by ‘O’ ) or BLOCKED (defined by ‘X’).
The cells can only be occupied by an object known as Sensor (this has its own class).
BLOCKED cells cannot be traversed on.
Each time the robot must move, it receives a direction from the sensor. So in the beginning the robot would be placed on the grid and it would drop a sensor and get a direction from it, or get a direction from a pre-existing sensor.

Now that I’ve explained my program,
my specific question is, I have my GridMap class

public class GridMap {
  private int height;
  private int width;
  private char[][] grid;


  public GridMap(int x, int y) { 
    height=x;
    width=y;  
    grid = new char [x][y];
  }
  public int getHeight(){
    return height;
  }
  public int getWidth(){
    return width;
  }
  public String toString(){
    String s1 = 
    return s1;
  }
  public char getElementAt(int x, int y){
  }
  public void setElementAt(int x, int y){
  }
  public boolean isCellBlocked(int x, int y){
  }
  public double getCoverageIndex(){
    return COVERAGE_INDEX;
  }
}

What I want to know is how can I represent my 2D char array as a string of -, O’s and X’s.
I tried to be as detailed as possible, if anyone has any questions I’d be willing to answer asap.
Any help will be highly appreciated.
Thanks

Varun

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:29:01+00:00Added an answer on May 28, 2026 at 3:29 pm

    Is this what you mean?

    public String toString()
    {
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i < getHeight(); i++)
        {
            for(int j = 0; j < getWidth(); j++)
            {
                builder.append(grid[i][j]);
            }
        }    
        return builder.toString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a program using the LRV(Least recently visited) Algorithm. Basically, I design
I am making a program in which I established connection with sql server using
I am making a program which plays minesweeper automaticaly. I am using the mouse
I'm making a program in vb6. i;d like to connect using a proxy through
I am using the cool map making program DIY map and i want to
I am making a request to a CGI program using AJAX. The response sends
I'm making a program which the user build directories (not in windows, in my
I'm making a program that retrieves decently large amounts of data through a python
I'm making a program using RBing. But I unable to get 50 links. How
I'm making a program which needs to be listening for UDP Data at all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.