{"size": 1638, "ext": "js", "max_stars_repo_path": "js/scripts.js", "max_stars_repo_name": "ahorod/movie-ticket", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/scripts.js", "max_issues_repo_name": "ahorod/movie-ticket", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/scripts.js", "max_forks_repo_name": "ahorod/movie-ticket", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.2, "max_line_length": 73, "alphanum_fraction": 0.6306471306}
//business logic
//constructor for Ticket
function Ticket(movie, time, age) {
  this.movie = movie;
  this.time = time;
  this.age = parseInt(age);
  this.price = 20;
}//close constructor
//prototype generates ticket information
Ticket.prototype.ticketInfo = function() {
  return this.movie + " " + this.time + " " + this.age ;
}//close prototype
//prototype calculates ticket price
Ticket.prototype.ticketPrice = function() {
  if (this.age < 12 || this.age > 54) {
    this.price -=5;
  }

  var thisTime = (parseInt(this.time));
  if (thisTime > 11 && thisTime < 16) {
    this.price-=5;
  }
  console.log($("select.movieoption").hasClass("old"));
  console.log($("select.movie option"));

  if ( (this.movie).includes("old")) {
    this.price -=5;
  }
  return(this.price);
}//close prototype
//function resets form
function resetFields() {
    $("select.movie").val("");
    $("input#time").val("");
    $("input#input-age").val("");
}

// user interface logic
$(document).ready(function() {


  $("form#new-ticket").submit(function(event) {
    event.preventDefault();

    var inputtedMovie = $("select.movie").val();
    var inputtedTime= $("input#time").val();
    var inputtedAge= $("input#input-age").val();

    var newTicket = new Ticket(inputtedMovie, inputtedTime, inputtedAge);

    var resultPrice = newTicket.ticketPrice();


      $("#show-price").show();
      $("#new-movie").text(newTicket.movie);
      $("#new-time").text(newTicket.time);
      $("#new-age").text(newTicket.age);
      $("#new-price").text(resultPrice);
      console.log(inputtedMovie, inputtedTime, inputtedAge);

    resetFields();

  });
});
