/* CST8110 - Introduction to Computer Programming
 * Section: 800
 * Semester: 20W
 * Professor: Piyush Jangam
 * Student ID: 040750891
 * Student Email: ross0272@algonquinlive.com
 * Practical Assessment 1
 */

public class File {
    private int numFiles;

    // Initial constructor
    public File(int numFiles) {
        this.numFiles = numFiles;
    }

    // Getter method for numFiles
    public int getNumFiles() {
        return numFiles;
    }

    // Determines if the file is empty (no files)
    public boolean isEmpty() {
        return (numFiles == 0);
    }

    /* Removes the specified number of files, assuming that number is valid by the rules of the
     * game. Assuming more than 1 file remaining, half or less of the files can be removed.
     * Method returns true if the files are successfully removed, which only happens if the
     * inputted number is valid.
     */
    public boolean removeFiles(int numToRemove) {
        // Checks whether input is too low
        if (numToRemove < 1) {
            System.out.println("Sorry, you must remove at least one file!");
            return false;
        }
        // Checks whether input is too high
        else if ((numFiles > 1) && (numToRemove > (numFiles / 2))) {
            System.out.println("Sorry, that's too many files!");
            return false;
        }
        // Input is in the acceptable range
        else {
            numFiles -= numToRemove;
            return true;
        }
    }
}
