简体   繁体   English

在数独游戏Android中撤消,重做

[英]Undo, Redo in Sudoku game Android

I'm trying to implement a undo and redo button in my android sudoku game, but it's complicated cause the user can draft(put in numbers they think could potentially be the answer to a cell), insert value they think it is, remove specific number from draft or value and delete all the draft values. 我试图在我的Android数独游戏中实现撤消和重做按钮,但这很复杂,因为用户可以起草(输入他们认为可能是单元格答案的数字),插入他们认为是的值,删除特定内容从草稿或值中编号,然后删除所有草稿值。 I was thinking of using a stack that holds some sort of object that saves the state of another object and just pop then revert it back, but I can't seem to find anything that does that. 我当时正在考虑使用一个保存某种对象的堆栈,该对象可以保存另一个对象的状态,然后弹出然后将其还原回去,但是我似乎找不到任何能够做到这一点的东西。 The momento object seems to be the closest, but I think that only saves 1 state and returns that state. 瞬间对象似乎是最接近的,但我认为只保存1状态并返回该状态。 Any suggestions? 有什么建议么?

Cell{
isNotEditable
DraftValue
Value
X
Y
}

SudokuStep{
ArrayList<Cell>
}

You can keep all cells for each step, and keep steps in ArrayList then move between steps. 您可以保留每个步骤的所有单元格,并将步骤保留在ArrayList中,然后在步骤之间移动。 You ofc have to modify steps wheter user didn't redo and moved etc 您必须修改用户没有重做和移动的步骤

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM