import json
import os

from utils import yellow, red, blue, green
from queue import Queue


class Agency(object):
  def __init__(self, name):
    self.name = name

    self.booked_phone = Queue()
    self.booked_cash = Queue()
    self.tickets = Queue()

  def open(self):
    os.system("clear")
    print blue("Welcome to %s" % green(self.name))
    print blue("========================")
    while True:
      print red("How may I help you?")
      print yellow("1. Buy a ticket\n"
                   " 2. Book a ticket by phone\n"
                   " 3. Book a ticket\n"
                   " 4. Cancel booking\n"
                   " 5. See how many money do you have\n"
                   " 6. Goodbye!\n")
      option = raw_input(green("I want to: "))
      if option == "1":
        self.buy_ticket()
      if option == "2":
        self.book_ticket_by_phone()
      if option == "3":
        self.book_ticket()
      if option == "4":
        self.cancel_booking()
      if option == "5":
        self.money()
      if option == "6":
        break

  def load(self):
    with open("logs/now") as f:
      content = json.load(f.read())

      self.booked_phone.load(content['phone'])
      self.booked_cash.load(content['cash'])
      self.tickets.load(content['tickets'])

@@ -705,16 +705,17 @@
 ye!%5Cn%22)%0A
+%0A
       op
@@ -753,16 +753,17 @@
 to: %22))%0A
+%0A
       if
@@ -1014,16 +1014,17 @@
 money()%0A
+%0A
       if
@@ -1039,16 +1039,16 @@
 == %226%22:%0A
-
         
@@ -1054,16 +1054,490 @@
  break%0A%0A
+  def buy_ticket(self):%0A    option = raw_input(%22Do you want a specific number?%5BY/n%5D: %22)%0A    if option in %5B'Y', 'y', 'YE', 'ye', 'YES', 'yes'%5D:%0A      number = raw_input(%22Please insert a number: %22)%0A      if number not in self.booked_phone and number not in self.booked_cash:%0A        print %22Your number is %25s%22 %25 self.tickets.pop()%0A      else:%0A        print %22Number already taken%22%0A        return self.buy_ticket()%0A    else:%0A      print %22Your ticket is %25s%22 %25 self.tickets.pop()%0A%0A
   def lo

IMplement buy ticket