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 8942763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:36:00+00:00 2026-06-15T11:36:00+00:00

Ok I really need help with all of this, I have a class named

  • 0

Ok I really need help with all of this, I have a class named Board.java
The board is represented as a two-dimensional array of char’s. A turtle can leave a trail by writing a character into each position on the board that it passes through.
There will be two constructors for the board. The default constructor takes no arguments and will create a board with 10 rows and 25 columns. Set each element in the board to be a blank space. The second constructor will take two integers that specify the number of rows and the number of columns, respectively. If the number of rows or columns specified is below 1, set the value to 1. If the number of rows or columns specified is greater than 80, set the value to 80. Set each element in the board to be a blank space.
The class will need a clearBoard method. This will put a blank space in every position, except
those positions occupied by turtles. Turtles mark their positions using the characters ‘0’, ‘1’, ‘2’, … ‘9’.

I have the following completed but I am not sure my constructors are right, and I don’t know how to start the clearBoard method. Help please!!

import java.util.Arrays;

public class Board {

    private char [][] theBoard;

     public Board() { // This will not take any arguments 


        theBoard = new char [10][25]; //10 rows and 25 columns
        for (int row = 0; row < theBoard.length; row++ ) {
             for (int col = 0; col < theBoard[row].length; col++ )
                 theBoard [row][col] = ' ';
    System.out.println();
        }
   }

   public Board (int [][] theBoardArray) { 
        char [][] theBoard = new char [theBoardArray.length] [theBoardArray[0].length];
        for (int row = 0; row < theBoard.length; row++ ) {
                if (row <1)
                    row = 1;
                else if (row >80)
                    row =80;
             for (int col = 0; col < theBoard[row].length; col++ ){
                if (col <1)
                    col = 1;
                else if (col >80)
                    col =80;
                 theBoard [row][col] = ' ';
            }
    System.out.println();
        }
    }
  • 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-06-15T11:36:01+00:00Added an answer on June 15, 2026 at 11:36 am

    Fixed some parts, cleaned up a bit and added the rest you want. Explanations are in code comments.

    public class Board {
    
        private char [][] theBoard;
    
        public Board() { // This will not take any arguments
            this(10, 25); // calls the other constructor
            // avoid duplicate code, where possible
        }
    
        // takes number of rows and collumns
        public Board (int rows, int cols) {
            // fix illegal row and column numbers
            rows = fixNumber(rows);
            cols = fixNumber(cols);
            // create the board and fill it with ' '
            theBoard = new char [rows][cols];
            for (int row = 0; row < theBoard.length; row++) {
                for (int col = 0; col < theBoard[row].length; col++)
                    theBoard[row][col] = ' ';
            }
        }
    
        private int fixNumber(int number) {
            if (number < 1) {
                return 1;
            } else if (number > 80) {
                return 80;
            } else {
                return number;
            }
        }
    
        // almost like constructor, just does not create a new char[][] and
        // only puts ' ' into fields not containing any of '0' - '9'
        public void clearBoard() {
            for (int row = 0; row < theBoard.length; row++ ) {
                for (int col = 0; col < theBoard[row].length; col++) {
                    if (theBoard[row][col] < '0' || theBoard[row][col] > '9') {
                        theBoard[row][col] = ' ';   
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We Really need some help on this one: We've Struggled with all the Apple
I really need help here. I'm desperate at this point. I have NSOperation that
Afternoon all, I really need your help as this is a Nightmare! I was
first of all, I'm really thankful for all your help. I need just one
I really need help with this last part of my program. I need to
I Really need help in this ... I'm building an application where I need
I really need help this time - Joomla 2.5 and latest K2. I'm using
I really need help on this one. I am having a simple login form
Sorry to bother again, but I really need help transforming this Python2 code into
I am trying to convert this to python. I just really need help with

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.