package org.lucci.madhoc.script;

import java.io.File;
import java.io.IOException;

public class Task 
{
    private String name;
    private File file;
    
    public Task(File directory, String name)
    {
        this.name = name;
        this.file = new File(directory, this.name + "-ok");
        
        if (this.file.delete())
        {
            throw new IllegalStateException("cannot delete file " + this.file.getAbsolutePath());
        }
    }
    
    public void ok()
    {
        try
        {
            if (this.file.createNewFile())
            {
                throw new IllegalStateException("problem while creating file " + this.file.getAbsolutePath());
            }
        } catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new IllegalStateException("problem while creating file " + this.file.getAbsolutePath());
        }
    }
}