diff --git a/email.txt b/email.txt index e69de29..a94c314 100644 --- a/email.txt +++ b/email.txt @@ -0,0 +1 @@ +loganbishop2202@gmail.com diff --git a/gitScript1.sh b/gitScript1.sh index e69de29..ca106e0 100644 --- a/gitScript1.sh +++ b/gitScript1.sh @@ -0,0 +1,9 @@ +git init +git branch -M main +git add helloworld.py +git commit -m "Add helloworld.py" +git switch -c branch1 +git add git_check.py +git commit -m "Add git_check.py" +git switch main +git merge branch1 diff --git a/gitScript2.sh b/gitScript2.sh index e69de29..1389d04 100644 --- a/gitScript2.sh +++ b/gitScript2.sh @@ -0,0 +1,6 @@ +git clone https://github.com/BYUComputingBootCampTests/git-clone.git . +git log --oneline +git diff b1cab e4c1d -- door.py +git restore --source=b1cab -- door.py +git add door.py +git commit -m "Restore previous version of door.py" diff --git a/repo2/.gitignore b/repo2/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/repo2/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/repo2/Readme.md b/repo2/Readme.md index 4279e80..4fbbce0 100644 --- a/repo2/Readme.md +++ b/repo2/Readme.md @@ -1 +1 @@ -This is the folder for the second task indicated. +This repository exists solely to support the gitTest repository. Change none of its files unless you know exactly what you are doing! \ No newline at end of file diff --git a/repo2/door.py b/repo2/door.py new file mode 100644 index 0000000..a80847b --- /dev/null +++ b/repo2/door.py @@ -0,0 +1,43 @@ +import random + + +class Door: + def __init__(self, key): + self.key = key + self.locked = True + + def unlock(self, trial_key): + if self.locked and self.key == trial_key: + self.locked = False + + def lock(self, trial_key): + if not self.locked and self.key == trial_key: + self.locked = True + + +class SecretDoor(Door): + def __init__(self, keylist): + randomKey = random.choice(keylist) + self.keylist = keylist + super().__init__(randomKey) + + def key_guess(self): + print( + "You are confronted with a locked door. You need to unlock it to proceed." + ) + print(f"Before you are laid {len(self.keylist)} keys: ") + for index, i in enumerate(self.keylist): + print(f"\t{index}: {i}") + key_guessed = False + while not key_guessed: + print("Guess a key by entering its number") + try: + trial_key = self.keylist[int(input())] + self.unlock(trial_key) + if not self.locked: + key_guessed = True + else: + print("The key jostles in the lock, but it fails to open the door.") + except Exception as e: + print("Invalid guess!") + print("You guessed it!") diff --git a/repo2/key.py b/repo2/key.py new file mode 100644 index 0000000..bbfe295 --- /dev/null +++ b/repo2/key.py @@ -0,0 +1,13 @@ +class Key: + def __init__(self, color, teeth): + self.color = color + self.teeth = teeth + + def __eq__(self, other): + if not isinstance(other, Key): + return NotImplemented + return self.color == other.color and self.teeth == other.teeth + + def __str__(self): + outStr = "A " + self.color + " " + str(self.teeth) + "-toothed key" + return outStr diff --git a/repo2/main.py b/repo2/main.py new file mode 100644 index 0000000..d437089 --- /dev/null +++ b/repo2/main.py @@ -0,0 +1,17 @@ +import door +import key + + +def main(): + keylist = [ + key.Key("red", 3), + key.Key("blue", 4), + key.Key("white", 1), + key.Key("green", 2), + ] + castle_door = door.SecretDoor(keylist) + castle_door.key_guess() + + +if __name__ == "__main__": + main()