Choosing design method for ladder-like word game

前端 未结 1 1759
粉色の甜心
粉色の甜心 2021-01-22 14:15

I\'m trying to build a simple application, with the finished program looking like this :

ladder-like game http://img199.imageshack.us/img199/6859/lab9a.jpg

I wil

相关标签:
1条回答
  • 2021-01-22 14:27

    Your grid is your internal data model (i.e. none except for you will use it). That's why you can choose the one which is the most convinient for you.

    I would prefer the first solution with arrays because the code will be a little more readable (at least for me). Just compare:

    grid[3][4] = element;
    

    and

    grid.get(3).add(4, element);
    

    Moreover, if you want to use collections, then you probably need to use

    Map<Integer, List<Element>> grid
    

    where Integer-key represents row index. With list of lists it's very difficult to insert new words (just think, how would you implement that with lists only).

    0 讨论(0)
提交回复
热议问题