Skip to content

Commit

Permalink
Merge pull request #4 from tylerlight071/Bug-Fixes
Browse files Browse the repository at this point in the history
Minor Bug Fixes
  • Loading branch information
tylerlight071 authored Jan 29, 2024
2 parents 5e64d24 + 13077a4 commit 3941d90
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
13 changes: 7 additions & 6 deletions FurEver_Friends.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def change_admin_password():

def login():
while True:
print("\n👤 User Login 👤")
username = input("\nEnter your username: ")
password = getpass.getpass("Enter your password: ")

Expand Down Expand Up @@ -81,7 +82,7 @@ def main():
json.dump(DEFAULT_ANIMAL_DATA, animal_file, indent=4)

while True:
print(Fore.CYAN + "\nWelcome to the Animal Adoption System!" + Style.RESET_ALL)
print(Fore.CYAN + "\n🐕 Welcome to FurEver Friends Management System! 🐈" + Style.RESET_ALL)
print("\n1. " + Fore.GREEN + "Login" + Style.RESET_ALL)
print("2. " + Fore.YELLOW + "Exit" + Style.RESET_ALL)
choice = input("\nPlease select an option: ")
Expand All @@ -92,11 +93,11 @@ def main():
if username is not None:
while True:
clear_screen()
print(Fore.CYAN + "\nMenu:" + Style.RESET_ALL)
print("\n1. " + Fore.GREEN + "Add a new animal" + Style.RESET_ALL)
print("2. " + Fore.GREEN + "View all animals" + Style.RESET_ALL)
print("3. " + Fore.GREEN + "Change animal adoption status" + Style.RESET_ALL)
print("4. " + Fore.YELLOW + "Logout" + Style.RESET_ALL)
print(Fore.CYAN + "\n📖 Main Menu 📖" + Style.RESET_ALL)
print("\n1. " + Fore.GREEN + "🐶 Add a new animal" + Style.RESET_ALL)
print("2. " + Fore.GREEN + "🔎 View all animals" + Style.RESET_ALL)
print("3. " + Fore.GREEN + "🏡 Change animal adoption status" + Style.RESET_ALL)
print("4. " + Fore.YELLOW + "🔐 Logout" + Style.RESET_ALL)
option = input("\nPlease select an option: ")

if option == '1':
Expand Down
54 changes: 45 additions & 9 deletions add_animal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,49 @@
ANIMAL_DATA_FILE = "animals.json"

def add_animal():
clear_screen()
animals = load_data(ANIMAL_DATA_FILE)
name = input("\nEnter the animal's name: ")
species = input("Enter the animal's species: ")
breed = input ("Enter the animal's breed: ")
age = input ("Enter the animal's age: ")
animals[name] = {'species': species, 'breed': breed, 'age': age, 'adopted': False}
save_data(animals, ANIMAL_DATA_FILE)
print(Fore.GREEN + "\nAnimal added successfully!" + Style.RESET_ALL)
time.sleep(2)

while True:
clear_screen() # Clear the screen before prompting for input

name = input("\nEnter the animal's name: ")
if not name.strip(): # Check if the name is empty
print(Fore.RED + "Invalid input. Please enter the animal's name." + Style.RESET_ALL)
input(Fore.GREEN + "Press Enter to continue..."+ Style.RESET_ALL)
continue

species = input("Enter the animal's species: ")
if not species.strip(): # Check if the species is empty
print(Fore.RED + "Invalid input. Please enter the animal's name." + Style.RESET_ALL)
input(Fore.GREEN + "Press Enter to continue..."+ Style.RESET_ALL)
continue

breed = input("Enter the animal's breed: ")
if not breed.strip(): # Check if the breed is empty
print(Fore.RED + "Invalid input. Please enter the animal's name." + Style.RESET_ALL)
input(Fore.GREEN + "Press Enter to continue..."+ Style.RESET_ALL)
continue

age = input("Enter the animal's age: ")
if not age.strip(): # Check if the age is empty
print(Fore.RED + "Invalid input. Please enter the animal's name." + Style.RESET_ALL)
input(Fore.GREEN + "Press Enter to continue..."+ Style.RESET_ALL)
continue
elif not age.isdigit(): # Check if the age is a valid number
print(Fore.RED + "Invalid input. Please enter the animal's name." + Style.RESET_ALL)
input(Fore.GREEN + "Press Enter to continue..."+ Style.RESET_ALL)
continue

age = int(age) # Convert age to an integer

# Assuming age should be a positive number
if age <= 0:
print(Fore.RED + "Invalid input. Please enter the animal's name." + Style.RESET_ALL)
input(Fore.GREEN + "Press Enter to continue..."+ Style.RESET_ALL)
continue

animals[name] = {'species': species, 'breed': breed, 'age': age, 'adopted': False}
save_data(animals, ANIMAL_DATA_FILE)
print(Fore.GREEN + "\nAnimal added successfully!" + Style.RESET_ALL)
time.sleep(2)
break # Break the loop after successfully adding the animal
4 changes: 2 additions & 2 deletions view_animals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def print_animal_table(animals):
"""Prints the table of animals."""
print("\n🐾 " + Fore.CYAN + "List of Animals" + Style.RESET_ALL + " 🐾")
print("--------------------------------------------------------------------------------------------")
print("| " + Fore.YELLOW + "Name".ljust(20) + Style.RESET_ALL + "| " + Fore.YELLOW + "Species".ljust(20) + Style.RESET_ALL + "| " + Fore.YELLOW + "Breed".ljust(25) + Style.RESET_ALL + "| " + Fore.YELLOW + "Age".ljust(6) + Style.RESET_ALL + " | " + Fore.YELLOW + "Adopted".ljust(8) + Style.RESET_ALL + " |")
print("| " + Fore.YELLOW + "Name".ljust(20) + Style.RESET_ALL + "| " + Fore.YELLOW + "Species".ljust(20) + Style.RESET_ALL + "| " + Fore.YELLOW + "Breed".ljust(25) + Style.RESET_ALL + "| " + Fore.YELLOW + "Age".ljust(5) + Style.RESET_ALL + " | " + Fore.YELLOW + "Adopted".ljust(9) + Style.RESET_ALL + " |")
print("--------------------------------------------------------------------------------------------")

for name, data in animals.items():
Expand Down Expand Up @@ -105,7 +105,7 @@ def view_animals():
print_animal_table(animals)

while True:
print(Fore.CYAN + "\nMenu:" + Style.RESET_ALL)
print(Fore.CYAN + "\n⚙️ Options ⚙️" + Style.RESET_ALL)
print("\n1. " + Fore.GREEN + "Search for animal" + Style.RESET_ALL)
print("2. " + Fore.GREEN + "Sort animals" + Style.RESET_ALL)
print("3. " + Fore.GREEN + "Filter animals" + Style.RESET_ALL)
Expand Down

0 comments on commit 3941d90

Please sign in to comment.