Question

I need to translate this from Java to ObjC, problem is I'm not sure exactly what the code in Java is doing (to be specific the portion from int num to the closing } on the if statement below it). I'm not looking for a direct translation, but more of an explanation and maybe a pointer in the right direction.

-Java portion

 //make array and display match
 for(int row = 0; row < NUM_ROWS; row ++)
 {
     for(int col = 0; col < NUM_COLUMNS; col ++)
     {
         int num = grid[row][col];
         if(grid[row][col] == 1)
         {
             g.setColor(new Color(100,0,255));
             g.fillRect(col * CELL_WIDTH, row * CELL_WIDTH + Y_OFF_SET, CELL_WIDTH, CELL_WIDTH);
         }
     }
 }

-What I have so far

NSMutableArray* (name) = [[NSMutableArray alloc] init];
for(int row = 0; row < NUM_ROWS; row++)
{
    NSMutableArray* (name) = [[NSMutableArray alloc] init];
    for(int col = 0; col < NUM_COLUMNS; col++)
    {
        Unsure for here
    }
}
Was it helpful?

Solution

g is (almost for sure) object of class java.awt.Graphics

See descriptions for setcolor() and fillRect() methods

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top