Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Set a flag to determine if the user is cheating
- is_cheating = false
- # Define a function to check if the user is cheating
- def check_for_cheats(input)
- # Set a list of cheats
- cheats = ["cheat1", "cheat2", "cheat3"]
- # Iterate through the list of cheats
- cheats.each do |cheat|
- # If the input contains a cheat, set the flag to true and break out of the loop
- if input.include?(cheat)
- is_cheating = true
- break
- end
- end
- end
- # Prompt the user for input
- print "Enter a command: "
- user_input = gets.chomp
- # Check if the user is cheating
- check_for_cheats(user_input)
- # If the user is cheating, display a message and exit the program
- if is_cheating
- puts "Cheating is not allowed!"
- exit
- end
- # If the user is not cheating, continue with the program
- puts "Valid input"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement