Ice Cream Store

public class IceCream {
    private static ArrayList<IceCream> iceCreams = new ArrayList<IceCream>();
    private String flavor;
    private int id;
    public static final long MINUTE = 1000;  // minute

    protected long created;
    protected long life; 

    public void startTime(){
        created = System.currentTimeMillis(); //sets startTime to current time
    }
    
    // constructor for ice cream objects
    public IceCream(String flavor) {
        this.flavor = flavor; //sets flavor to the flavor passed in
        this.id = IceCream.getIceCreamCount(); //sets id to the current num of ice creams

        iceCreams.add(this); // adds ice cream to the list of ice creams

        startTime();  // set time when ice cream is taken out
        life = created; // set offset for ice creams life
        this.setIceCreamLife(1);  // provide a default for ice creams life
    }

    // gets the number of ice creams
    public static int getIceCreamCount() {
        return iceCreams.size();
    }

    // id getter
    public int getId() {
        return id;
    }

    public static ArrayList<IceCream> getIceCreams() {
        return iceCreams;
    }

    // toString method for ice cream objects
    public String toString(){
        return id + ". " + flavor + "  Life: " + getIceCreamLife() + " minutes";
    }

    // Sets the life of the ice cream
    public void setIceCreamLife(int minutes) {
        life += minutes * IceCream.MINUTE;  // add minutes to life
    }

    // increments the life of the ice cream
    public void removeIceCreamLife(){
        life -= IceCream.MINUTE;
    }

    // gets the amount of time remaining for the ice cream to melt
    public double getIceCreamLife() { 
        return (life - created) / IceCream.MINUTE;
    }

    // Checks if the ice cream has not melted yet
    public boolean hasIceCreamLife() { 
        return life > created;
    }

    // prints non melted ice creams
    public static void printIceCreams() {
        System.out.println("Non-melted Ice Creams: ");   
        for (IceCream iceCream: IceCream.iceCreams) {
            if (iceCream.hasIceCreamLife())  // Non melted ice cream check
                System.out.println(iceCream);
        }
    }



    public static void main(String[] args){
        System.out.println("Number of Ice Creams: " + IceCream.getIceCreamCount());
        
        IceCream[] iceCreams = {
            new IceCream("Vanilla"),
            new IceCream("Chocolate")
        };
    /* 
        for(IceCream iceCream: iceCreams){
            System.out.println(iceCream);
        }
    */
        IceCream.printIceCreams();
        System.out.println("Number of Ice Creams: " + IceCream.getIceCreamCount());

    }

}
IceCream.main(null);
Number of Ice Creams: 0
Non-melted Ice Creams: 
0. Vanilla  Life: 1.0 minutes
1. Chocolate  Life: 1.0 minutes
Number of Ice Creams: 2
public class Gelato extends IceCream {
    private int scoops = 0;
    private int calories;

    public Gelato(String flavor, int calories) {
        super(flavor);  // calls the constructor of the ice cream class
        this.calories = calories;  
        super.setIceCreamLife(5);  // adds 5 minute to default ice cream life
    }

    @Override
    public void removeIceCreamLife(){
        life -= 0.5 * IceCream.MINUTE;
    }

    @Override
    public String toString() {      
        return(super.toString() + ", " + this.calories);
    }

    public static void main(String[] args){
        System.out.println("Number of Ice Creams: " + IceCream.getIceCreamCount());
        
        Gelato[] gelatos = {
            new Gelato("Vanilla Gelato", 100),
            new Gelato("Chocolate Gelato", 200),
            new Gelato("Strawberry Gelato", 450)
        };

        for(Gelato gelato: gelatos){
            System.out.println(gelato);
        }

        System.out.println("Number of Ice Creams: " + IceCream.getIceCreamCount());
    }
}
Gelato.main(null);
Number of Ice Creams: 2
2. Vanilla Gelato  Life: 6.0 minutes, 100
3. Chocolate Gelato  Life: 6.0 minutes, 200
4. Strawberry Gelato  Life: 6.0 minutes, 450
Number of Ice Creams: 5
class CheckOut extends TimerTask {
    public void run() {
       System.out.println("Hello World!"); 
    }
}
// Library Simulation
public class IceCreamSim {

    public static void main(String[] args) throws InterruptedException {  
        int minutes = 5; // Simulation minutes
        // Sleep in loop creates delay for simulation
        for (int i = 0; i < minutes; i++) {
            System.out.println("Minute: " + i);
            IceCream.printIceCreams();
            System.out.println();
            Thread.sleep(IceCream.MINUTE);  // Part 3.4, Use a sleep in Java to assist with simulation
            // Loop through books in Library
            for (IceCream iceCream : IceCream.getIceCreams()) {
                iceCream.removeIceCreamLife();  // apply aging formula
            }

        }
        
    }
}
IceCreamSim.main(null);
Minute: 0
Non-melted Ice Creams: 
0. Vanilla  Life: 1.0 minutes
1. Chocolate  Life: 1.0 minutes
2. Vanilla Gelato  Life: 6.0 minutes, 100
3. Chocolate Gelato  Life: 6.0 minutes, 200
4. Strawberry Gelato  Life: 6.0 minutes, 450

Minute: 1
Non-melted Ice Creams: 
2. Vanilla Gelato  Life: 5.0 minutes, 100
3. Chocolate Gelato  Life: 5.0 minutes, 200
4. Strawberry Gelato  Life: 5.0 minutes, 450

Minute: 2
Non-melted Ice Creams: 
2. Vanilla Gelato  Life: 5.0 minutes, 100
3. Chocolate Gelato  Life: 5.0 minutes, 200
4. Strawberry Gelato  Life: 5.0 minutes, 450

Minute: 3
Non-melted Ice Creams: 
2. Vanilla Gelato  Life: 4.0 minutes, 100
3. Chocolate Gelato  Life: 4.0 minutes, 200
4. Strawberry Gelato  Life: 4.0 minutes, 450

Minute: 4
Non-melted Ice Creams: 
2. Vanilla Gelato  Life: 4.0 minutes, 100
3. Chocolate Gelato  Life: 4.0 minutes, 200
4. Strawberry Gelato  Life: 4.0 minutes, 450