// Arup Guha
// 11/1/2026
// Buyer class for
// COP 3330 Fall 2026 Program 7C: In Demand Tickets with Priority

import java.util.*;

public class Buyer implements Comparable<Buyer> {
	
	private String name;
	private int priority;
	private int numTickets;
	
	public Buyer(String myName, int myPriority, int myNumTickets) {
		name = myName;
		priority = myPriority;
		numTickets = myNumTickets;
	}
	
	// We need this...
	public int getNumTickets() {
		return numTickets;
	}
	
	// Pre-condition: 0 < numTix < numTickets.
	// Gives numTix tickets to this buyer.
	public void giveTickets(int numTix) {
		numTickets -= numTix;
	}
	
	public int compareTo(Buyer other) {
	
		// First go with priority.
		if (this.priority != other.priority)
			return this.priority - other.priority;
			
		// Next # tix.
		if (this.numTickets != other.numTickets)
			return this.numTickets - other.numTickets;
			
		// Guaranteed to break the tie!
		return this.name.compareTo(other.name);
	}
	
	// This is how we'll do it.
	public String toString() {
		return name;
	}

}