package org.academiadecodigo.bootcamp11.exceptions;

import org.academiadecodigo.bootcamp11.exceptions.file.*;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class Main {
    public static void main(String[] args) {
        // creating a disk with 2 free spaces for files
        FileManager manager = new FileManager(2);

        // logging in with the first user
        manager.login("ricardo");

        // creating 2 files to fill the disk
        manager.createFile("girls gone wild S39E80.avi");
        manager.createFile("cu de melancia declara um enum.rmvb");
        System.out.println(manager);
        manager.logout();

        // logging in with a different user
        manager.login("ivan");

        // trying to get an existing file
        File studyingMaterial =
                manager.getFile("cu de melancia declara um enum.rmvb");

        // creating a file when there's no space
        manager.createFile("enums são a resposta para tudo.pptx");

        // accessing a non-existing file
        File theAnswer = manager.getFile("enums são a resposta para tudo.pptx");

        manager.logout();

        // hacker trying to access a file without logging in
        System.out.println("Ring a-ling ding, I'm a ultra haxxor from Wikileaks.");
        File wikileaks =
                manager.getFile("cu de melancia declara um enum.rmvb");
        if (wikileaks == null)
            System.out.println("I'm a shitty hacker.");
        else
            System.out.println("YEAH, I'm the best hacker ever.");
    }
}
