Demo entry 6660233

code

   

Submitted by anonymous on Nov 14, 2017 at 15:27
Language: Java. Code size: 384 Bytes.

package train_tickets;

public class Ticket {
    private int _ticket_left;

    public Ticket(int n) { this._ticket_left = n; }

    public synchronized int sell(int n_tickets) {
        if (_ticket_left < n_tickets) return -1;
        else return _ticket_left -= n_tickets;
    }

    public synchronized int get_ticket_left() {
        return _ticket_left;
    }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).