package lab06.v2_contactos;

public class ContactTesting {
    public static void main(String[] args){

        // Creating new txt file
		ContactsStorageInterface contactsTXT = new ContactStorageTXT("lab06/v2_contactos/Contacts.txt");
		ContactsInterface storageTXT = new ContactsOperations();
        
		storageTXT.openAndLoad(contactsTXT);

		Contact ana = new Contact("Ana", 931234567);
		Contact tiago = new Contact("Tigs", 939876543);

		storageTXT.add(ana);
		storageTXT.add(tiago);

		storageTXT.saveAndClose();
		System.out.println("Contacts: \n");
		storageTXT.openAndLoad(contactsTXT);

		tiago = storageTXT.getByName("Tigs");

		storageTXT.remove(tiago);
		storageTXT.saveAndClose();
		System.out.println("Contacts post-deletion: \n");
		storageTXT.openAndLoad(contactsTXT);


		// Testing with premade txt file
		System.out.println("Contacts in existing file: \n");
		ContactsStorageInterface loadedContactsTXT = new ContactStorageTXT("lab06/v2_contactos/ContactsPremade.txt");
		ContactsInterface storageTXTPremade = new ContactsOperations();
		storageTXTPremade.openAndLoad(loadedContactsTXT);



     // Creating new bin file
		ContactsStorageInterface contactsBIN = new ContactStorageBIN("lab06/v2_contactos/Contacts.bin");
		ContactsInterface storageBIN = new ContactsOperations();
        
		storageBIN.openAndLoad(contactsBIN);

		Contact paulo = new Contact("Paulo", 934564567);
		Contact helder = new Contact("Helder", 964876543);

		storageBIN.add(paulo);
		storageBIN.add(helder);

		storageBIN.saveAndClose();
		System.out.println("Contacts: \n");
		storageBIN.openAndLoad(contactsBIN);

		helder = storageBIN.getByName("Helder");

		storageBIN.remove(helder);
		storageBIN.saveAndClose();
		System.out.println("Contacts post-deletion: \n");
		storageBIN.openAndLoad(contactsBIN);
    }
}
