Results 1 to 2 of 2
  1. #1
    mayhewj7 is offline Member
    Join Date
    Dec 2008
    Rep Power

    Default java help needed

    - i have an assignment to create a text grid. the system will allow the user to specify a row and column in the grid, and specify the character to be placed in the cell. after each modification the grid will be redisplayed.

    -must use a 2D array
    -it must consist of 3 classes including the driver
    -each time the system starts it should start with a blank slate
    -and each the user modifies the grid it should ask if they wont to do another modification or exit.

    This is what I have so far. i need some help to finish this thing up. If anyone could help i would greatly appreciate it. thanks

    public class Cell{
    private char letter = ' ';
    private int row;
    private int column;

    public Cell(){
    this.row = 0;
    this.column = 0;

    public void setLetter(char _letter){
    this.letter = _letter;

    public char getLetter(){
    return this.letter;

    public void setRow(int _row){
    this.row = _row;

    public int getRow(){
    return this.row;

    public void setColumn(int _column){
    this.column = _column;

    public int getColumn(){
    return this.column;

    // new class

    import java.util.*;

    public class CellInterface {
    private int option;
    private int columns;
    private int rows;
    private Cell[][] cells;
    private Scanner sc = new Scanner(;

    public CellInterface(){
    System.out.println("How many rows would you like? ");
    this.rows = sc.nextInt();
    System.out.println("How many columns would you like? ");
    this.columns = sc.nextInt();
    this.option = 1;
    this.cells = new Cell[rows][columns];
    for(int r = 0;r<this.cells.length; r++){
    for(int c = 0; c<this.cells[r].length;c++){
    Cell cell = new Cell();


    private void cellModifier(){

    while(option == 1)
    System.out.println("Enter a row: ");
    this.rows = sc.nextInt();
    System.out.println("Enter a column: ");
    this.columns = sc.nextInt();
    System.out.println("Enter a letter: ");

    System.out.println("Press 1 to modify or 2 to exit ");


    // new class

    public class CellDriver{

    public static void main(String[] args)



  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Rep Power


    Change class Cell to Cells. This class should have an instance property

    private char[][] cells = null;

    public Cells(int rows, int columns) {
    cells = new char[rows][columns];
    // Loop through the rows and columns to set each array entry to ''

    Add methods

    char getCharAt(int row, int column) {...}
    void setCharAt(int row, int column) {...}

    Your driver class will need access to the CellInterface methods, so make them at least default.

    Don't put the prompt for rows, columns logic in the CellInterface constructor. Create a getSetup() method that returns the rows and columns in an int[2].

    CellInterface needs methods

    int[] getSetup()

    char promptForChar()

    void displayValues(char[][] chars)

    CellDriver should have a main(). Have it create an instance and invoke the instance's run() method.

    The constructor need not do anything.

    public void run() {
    // put your driver logic here

    1. Prompt for the setup
    2. Prompt for cell values, one at a time, until null is returned
    3. Display the values

Similar Threads

  1. Help needed with downloader in java
    By falcommoney in forum New To Java
    Replies: 3
    Last Post: 01-28-2009, 01:31 PM
  2. Java Programmer Needed
    By ALATECjobs in forum Jobs Offered
    Replies: 0
    Last Post: 08-14-2008, 10:48 PM
  3. Help needed in Java
    By javanewbie in forum New To Java
    Replies: 2
    Last Post: 07-08-2008, 07:55 PM
  4. Java experts needed- 30 minute online Java projects
    By michelle in forum Jobs Offered
    Replies: 0
    Last Post: 03-05-2008, 11:47 PM
  5. Java help needed
    By jeneal in forum New To Java
    Replies: 0
    Last Post: 11-21-2007, 03:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts