// Arup Guha
// 7/11/07
// Written for 2007 BHCSI Intermediate Class Homework

public class Movie {
	
	private String title;
	private double ticketPrice;
	private int numViewers;
	private double grossRevenue;

	// Creates an new Movie object that has never been seen,
	// with an original ticket price of price.
	public Movie(String movieTitle, double price) {
		title = movieTitle;
		ticketPrice = price;
		numViewers = 0;
		grossRevenue = 0;
	}
	
	// Returns the title of the current object.
	public String getTitle() {
		return title;
	}

	// Returns the ticket price of the current object.
	public double getTicketPrice() {
		return ticketPrice;
	}

	// Returns the total number of viewers for the current
	// object.
	public int getNumViewers() {
		return numViewers;
	}

	// Returns the gross revenue of the current object.
	public double getGrossRevenue() {
		return grossRevenue;
	}


	// Sells numTickets number of tickets for the current
	// Movie object. If numTickets is negative, no tickets
	// are sold.
	public void sellTickets(int numTickets) {
		
		if (numTickets > 0) {
			numViewers += numTickets;
			grossRevenue += ticketPrice*numTickets;
		}
	}

	// Gives away numTickets number of tickets away for free
	// for the current Movie object. If numTickets is 
	// negative, no tickets are given away.
	public void giveFreeTickets(int numTickets) {
		
		if (numTickets > 0)
			numViewers += numTickets;
	}

	// Returns true iff the gross revenue of the current
	// object exceeds $100,000,000.
	public boolean bigHit() {
		if (grossRevenue >= 100000000)
			return true;
		else
			return false;
	}
	

	// Creates a new Movie object with the same title as the
	// original with "Dos" concatenated to the end of it. The
	// ticket price will be one dollar less than that of the
	// current Movie object.
	public Movie makeSequel() {
		String newTitle = title + "Dos";
		Movie mySequel = new Movie(newTitle, ticketPrice-1);
		return mySequel;
	}

	// Increases the price a ticket to the current Movie object
	// by increase number of dollars. If increase is negative,
	// no change is made to the ticket price.
	public void upTicketPrice(double increase) {
		
		if (increase > 0)
			ticketPrice += increase;	
	}

	// Sets the price of a ticket to the current Movie object
	// to one dollar.
	public void moveToDollarTheater() {
		ticketPrice = 1;
	}

	// Returns a string representation of the current object.
	// In a reasonable fashion, this includes the title,
	// total number of viewers and gross revenue.
	public String toString() {
		return title+": Number of Viewers: "+numViewers+" Gross Revenue: "+grossRevenue;
	}

	// Returns a negative integer if the current movie object
	// has a smaller gross revenue than m, returns 0 if its
	// revenue is equal to m's revenue, and returns a positive
	// integer if its revenue is greater than m's.
	public int compareTo(Movie m) {
	
		
		if (this.grossRevenue < m.grossRevenue)
			return -1;
		else if (this.grossRevenue > m.grossRevenue)
			return 1;
			
		return 0;
	}

}