class Puzzle
{
public int PUZZLESIZE = 3;
public int numSteps = 0;
public Button[,] buttons;
public Puzzle(Form1 form1)
{
buttons = new Button[3, 3] { { form1.button1, form1.button2, form1.button3 },
{ form1.button4, form1.button5, form1.button6 },
{ form1.button7, form1.button8, form1.button9 } };
}
public Puzzle Clone()
{
return (Puzzle)this.MemberwiseClone();
}
public void reset()
{
//reset all 9 buttons color
}
public void flipcells()
{
//flip cells in the puzzle with color change
}
class Undo
{
Puzzle newPuzzle; //null value here. Why???
public Undo(Puzzle oldPuzzle)
{
Puzzle newPuzzle = oldPuzzle.Clone();
}
public void undo()
{
//back to previous step, ie the color of the buttons go back to previous color
}
이전 단계의 실행 취소 기능을 최대 4 회 실행하도록 요청하고 있습니다. "가장 쉬운 방법은 퍼즐의 복사본을 만들어 퍼즐 배열에 저장하는 것입니다.이를 위해 퍼즐을위한 Clone 메서드를 구현했습니다. 이렇게하면 완전히 새로운 퍼즐 세트가 퍼즐과 똑같은 설정으로 반환됩니다. 클론을 불렀다. " 이것은 강사가하는 말입니다. 그러나 저는 이것을 구현하는 방법을 아직 모릅니다.Object Clone에 대한 지원을 찾는
그런데 답변을 수락하는 것을 잊지 마십시오. –