2022 - Allow the player to create a new lock

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

Create a new method

  • Create a new method in the BreakThrough class called 'NewLock()'.

Now inside this new method

  • output the message 'How many conditions'
  • read in the players input
  • convert the input to an integer
  • Create a new lock (eg, Lock temp = new Lock())
  • create a for loop using the integer

Now inside the for loop

  • output the message 'Please enter a condtion: '
  • read in the players input
  • create a challenge by splitting the input (eg List<string> challenge = input.Split(',').ToList(); )
  • now add the challenge to the lock (eg temp.AddChallenge(challenge); )

Finally, outside of the for loop

  • add the new lock to the Locks (eg Locks.Add(temp); )
  • set the currentLock to the new lock