Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions email.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loganbishop2202@gmail.com
9 changes: 9 additions & 0 deletions gitScript1.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions gitScript2.sh
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions repo2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
2 changes: 1 addition & 1 deletion repo2/Readme.md
Original file line number Diff line number Diff line change
@@ -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!
43 changes: 43 additions & 0 deletions repo2/door.py
Original file line number Diff line number Diff line change
@@ -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!")
13 changes: 13 additions & 0 deletions repo2/key.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions repo2/main.py
Original file line number Diff line number Diff line change
@@ -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()