xyz Interview Question
AnalystsCountry: India
Interview Type: In-Person
class ticket:
def __init__(self, price, time_elapsed, sold):
self.price = price
self.time_elapsed = time_elapsed
self.sold = sold
print(self.price, self.time_elapsed, self.sold)
def demand(self):
print(self.price, self.time_elapsed, self.sold)
# Price will increased if time elapsed is less than 4 and ticket sold is more than 5
if self.time_elapsed < 4 and self.sold >= 5:
self.price += ((10/100) * self.price)
print("chargeable price",self.price)
# Price will decrease if time elapsed is more than 4 and no ticket is sold
elif self.time_elapsed >= 4 and self.sold == 0:
self.price -= ((10/100) * self.price)
print("chargeable price",self.price)
else:
print("chargeable price",self.price)
class userbasic:
def basic(self):
while(True):
user_input1 = int(input("Enter basic price"))
user_input2 = int(input("Enter time elapsed"))
user_input3 = int(input("Enter number of tickets sold"))
final_price = ticket(user_input1, user_input2, user_input3)
final_price.demand()
ticket_price=userbasic()
ticket_price.basic()
class ticket:
def __init__(self, price, time_elapsed, sold):
self.price = price
self.time_elapsed = time_elapsed
self.sold = sold
print(self.price, self.time_elapsed, self.sold)
def demand(self):
print(self.price, self.time_elapsed, self.sold)
# Price will increased if time elapsed is less than 4 and ticket sold is more than 5
if self.time_elapsed < 4 and self.sold >= 5:
self.price += ((10/100) * self.price)
print("chargeable price",self.price)
# Price will decrease if time elapsed is more than 4 and no ticket is sold
elif self.time_elapsed >= 4 and self.sold == 0:
self.price -= ((10/100) * self.price)
print("chargeable price",self.price)
else:
print("chargeable price",self.price)
class userbasic:
def basic(self):
while(True):
user_input1 = int(input("Enter basic price"))
user_input2 = int(input("Enter time elapsed"))
user_input3 = int(input("Enter number of tickets sold"))
final_price = ticket(user_input1, user_input2, user_input3)
final_price.demand()
ticket_price=userbasic()
ticket_price.basic()
we can have the below class as:-
- veedee May 11, 2017Movie:- movie_id , Movie_name , artists etc
Cinema:- Id , name , arrayList<Screen>;
Screen:- movie_id , show_id , ArrayList<Seat> , screen_id (pk)
Seat:- seat_id , row_num , cinema_id , isBooked ;
reserved_Seats:- reserved_id , seat_id , status
Ticket:- id , movie_id , cinema_id , city_id , user_name , show_id , double price;
Booking:-
booing_id , ticket_id , booking_time , user_id ;
API UpdatePrice():- here we can track the max(booking_time) from booking table and if(currTime - max(book_time) >=4 ) then ticket.setPrice(price-price*.10) ;
if select count (distinct booking_id) from booking in time Interval say 2 houres then Ticket.setPrice() whatever we want to set.