Difference between revisions of "2022 - Allow the player to create a new lock"
(Created page with "=What you need to do= * Create a new method in the BreakThrough class called 'NewLock()'. Now inside this new method: * output the message 'How many conditions' * read in the...") |
(→What you need to do) |
||
Line 1: | Line 1: | ||
− | = | + | =Create a new method= |
* Create a new method in the BreakThrough class called 'NewLock()'. | * Create a new method in the BreakThrough class called 'NewLock()'. | ||
− | Now inside this new method | + | =Now inside this new method= |
* output the message 'How many conditions' | * output the message 'How many conditions' | ||
* read in the players input | * read in the players input | ||
Line 9: | Line 9: | ||
* create a for loop using the integer | * create a for loop using the integer | ||
− | Now inside the for loop | + | =Now inside the for loop= |
* output the message 'Please enter a condtion: ' | * output the message 'Please enter a condtion: ' | ||
* read in the players input | * read in the players input | ||
Line 15: | Line 15: | ||
* now add the challenge to the lock (eg temp.AddChallenge(challenge); ) | * now add the challenge to the lock (eg temp.AddChallenge(challenge); ) | ||
− | Finally, outside of the for loop | + | =Finally, outside of the for loop= |
* add the new lock to the Locks (eg Locks.Add(temp); ) | * add the new lock to the Locks (eg Locks.Add(temp); ) | ||
* set the currentLock to the new lock | * set the currentLock to the new lock |
Latest revision as of 17:27, 27 November 2021
Contents
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