diff --git a/FurEver_Friends.py b/FurEver_Friends.py index 68c4b14..9ac8f0e 100644 --- a/FurEver_Friends.py +++ b/FurEver_Friends.py @@ -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: ") @@ -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: ") @@ -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': diff --git a/add_animal.py b/add_animal.py index 33cda82..66d4175 100644 --- a/add_animal.py +++ b/add_animal.py @@ -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 diff --git a/view_animals.py b/view_animals.py index 564685b..641b173 100644 --- a/view_animals.py +++ b/view_animals.py @@ -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(): @@ -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)