// Arup Guha
// 7/10/2015
// Class to test AddressBook
// Edited on 2/19/2026 for COP 3330, made so that we can create
// Blackbook as an object of class AddressBook, AddressBook2 or AddressBook3
// and it works!

import java.util.*;

public class RunAddressBook {

public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Instantiate AddressBook object
		AddressBook3 blackbook = new AddressBook3();

 		// Menu driven loop.
		menu();
		int choice = stdin.nextInt();
		
		// Go until user quits.
		while (choice!=5) {
	    
			// Only adds contact if there is room in AddressBook blackbook.
	    	if (choice == 1) {
		
				// Checks if we can add someone.
				if (blackbook.canAdd()) {
		    
		    		//Reads in all appropriate information.");
		    		System.out.println("Enter your friend\'s name:");
		    		String name = stdin.next();
		    		System.out.println("Enter their age.");
		    		int age = stdin.nextInt();
		    		System.out.println("Enter their phone number.");
		    		int number = stdin.nextInt();
		    		System.out.println("Enter the birthday, month then space then day.");
		    		int mon = stdin.nextInt();
		    		int day = stdin.nextInt();

		    		// Uses information to create Contact object, which is
		    		// a parameter to the addContact method.
		    		blackbook.addContact(new Contact(name,age,number,mon,day));
				}
				
				// Full case.
				else
		    		System.out.println("Sorry, can not add anyone, your blackbook is full.");
	    	}
	    
	    	// Implements rest of the choices by calling appropriate AddressBook methods on blackbook.
	    	else if (choice == 2) {
				System.out.println("What is the name of the contact you want to delete?");
				String name = stdin.next();
				boolean res = blackbook.deleteContact(name);
				
				// Print message accordingly based on success of action.
				if (res)
					System.out.println("Great, your contact has been deleted.");
				else
					System.out.println("Sorry that wasn't a valid contact to begin with. No action was taken.");
				
	    	}
	    	else if (choice == 3) {
				System.out.println("You have " + blackbook.numContacts() + " contacts.");
	    	}
	    	else if (choice == 4) {
				System.out.println(blackbook);
	    	}
	    	else if (choice !=5) {
				System.out.println("Sorry, that was an invalid menu choice, try again.");
	    	}
	    	menu();
	    	choice = stdin.nextInt();
		}
	
    }

	// Prints the menu of choices.
    public static void menu() {
		System.out.println("1.Add a new contact to your address book.");
		System.out.println("2.Delete a contact from your address book.");
		System.out.println("3.Print out the number of contacts you have.");
		System.out.println("4.Print out information of all of your contacts.");
		System.out.println("5.Quit.");
		System.out.println("Enter your menu choice:");
    }
}
