Railways_Enquiry_Program

 # Source Code :- 

# Indian Railway Program

import random


serial = ['45487', '44656', '8468', '5621', '4545465', '8451', '2', '454154854', '81541', '8465', '4864651', '8454', '443513', '6543651', '6542',

          '414565', '4578465', '46465764625', '46878645', '7874', '14512', '45464', '8456', '7854546', '8956132', '44542365', '45645132', '645412']

serial_random = random.choice(serial)


train_name = ['Rajdhani', 'Delhi', 'City', 'Local', 'Metro',

              'Kashmir', 'Indian', 'Chennai', 'Intercity', 'BadiGadi', 'Rault']

random_train = random.choice(train_name)


fare = [50, 100, 150, 200, 175, 245, 485, 152, 300, 350,

        500]                           # Credits :- Mandeep Yadav

fare_random = random.choice(fare)


train_time = ['12 PM', '12:30 PM', '1 PM', '1:30 PM', '2 PM', '2:30 PM', '3 PM', '3:30 PM', '4 PM', '4:30 PM', '5 PM', '5:30 PM', '6 PM', '6:30 PM', '7 PM', '7:30 PM',

              '8 PM', '8:30 PM', '9 PM', '9;30 PM', '10 PM', '6 AM', '6:30 AM', '7 AM', '7:30 AM', '8 AM', '8:30 AM', '9 AM', '9:30 AM', '10 AM', '10:30 AM', '11 AM', '11:30 AM']

random_time = random.choice(train_time)


platform_no = random.randint(0, 11)


seat_no = random.randint(0, 1000)


seat_random = random.randint(0, 50)


a = []



class Enquiry():

    def __init__(self, Name,):

        self.Name = Name

        self.fare = fare_random

        self.seat = seat_random


    def getStatus(self):

        print(f" : Train Name is '{self.Name} Express '")

        print(f" : Fare of {self.Name} Express is {fare_random} Rs \n")


    def seatStatus(self):

        print(f" : Available seat is {self.seat}\n")



class Book():

    formtype = "RailwayForm"


    def printdata(self):

        with open(f"C:\\Users\\Mandeep_PC\\Desktop\\Ticket_of_{self.name}.txt", "w") as i:


            i.write("=========================================================================================================================")

            i.write(

                "\n\n\t\t ' ' ' Passenger Details ' ' ' \n\t\t\t\t\t\t\t\t\t Helpline_No :- 100880029334")

            i.write(f"\n\n\t * Passenger Name --> {self.name}")

            i.write(f"\n\n\t * Passenger Destination --> {self.location}")

            i.write(f"\n\n\t * Passenger Gmail --> {self.email}")

            i.write(f"\n\n\t * Passenger Account_no --> {self.account}")


            if seat_no > 800:

                i.write(

                    "\n\n\t : Sorry due to heavy Rush your ticket has been NOT CONFIRMED !")

                i.write(

                    "\n\n\t : Your Money has been refunded shortly in your account ")

                i.write("\n\n\t\t ' ' '  Thanks for visiting Indian Railways ' ' ' ")

                i.write(

                    "\n\n\t\t                                \n\t\t\t\t\t\t\t\t\t      IRCTC OFFICIAL")

                i.write(

                    "\n\n=========================================================================================================================")

            else:

                i.write(

                    f"\n\n\t * Dear Passenger You Ticket has been CONFIRMED !\n\n\t * Your Serial no is --> {serial_random}\n\n\t * Your Seat no is --> {seat_no}")

                i.write(f"\n\n\t * Train Name --> {self.tr} Express")

                i.write(f"\n\n\t * Total Fare (fees) --> {self.fr} Rupees")

                i.write(

                    f"\n\n\t * Dear Passenger your train is arrive at '' platform no {platform_no} '' at '' {random_time} '' next day of Booking ")

                i.write(

                    "\n\n\n\t\t ' ' ' Thanks for visiting Indian Railways ' ' ' ")

                i.write(

                    "\n\n\t\t                                \n\t\t\t\t\t\t\t\t\t      IRCTC OFFICIAL")

                i.write(

                    "\n\n=========================================================================================================================")



class cancel():

    def si(self):

        with open(f"C:\\Users\\Mandeep_PC\\Desktop\\Ticket_of_{self.name}.txt", "r") as i:

            i.read()

        with open(f"C:\\Users\\Mandeep_PC\\Desktop\\Ticket_of_{self.name}.txt", "w") as i:

            i.write("=========================================================================================================================")

            i.write(

                "\n\n\t\t ' ' ' Passenger Details ' ' ' \n\t\t\t\t\t\t\t\t\t Helpline_No :- 100880029334")

            i.write(f"\n\n\t * Passenger Name --> {self.name}")

            i.write(

                f"\n\n\t**** Your ticket has been cancelled as per your request ****")

            i.write(

                "\n\n\t\t                                \n\t\t\t\t\t\t\t\t\t      IRCTC OFFICIAL")

            i.write("\n\n=========================================================================================================================")

        print("\t\t **** Your ticket has been cancelled as per your request **** ")



while True:

    print("\n    \t\t\t\t******* WELCOME TO INDAIN RAILWAYS *******")

    print(

        f"\n : These are some following instructions :-\n\t--> These Trains are goes all over India :- {train_name}\n\t--> For General Inquiry type ' Enquiry ' \n\t--> For Booking a ticket type ' Book ' \n\t--> For Canceling a ticket type ' Cancel ' \n\t--> For checking your name in our database type ' Check ' ")

    instruction = input("\n --> ")


    if instruction == 'Enquiry':

        a = input(" : Enter Train name :- ")

        Enquiryclass = Enquiry(a)

        Enquiryclass.getStatus()

        Enquiryclass.seatStatus()


    elif instruction == 'Book':


        Bookclass = Book()

        Bookclass.name = input(" : Your Name :- ")

        a.append(Bookclass.name)

        Bookclass.location = input(" : Your Destination :- ")

        Bookclass.email = input(" : Your Email :- ")

        train_name = ['Rajdhani', 'Delhi', 'City', 'Local', 'Metro',

                      'Kashmir', 'Indian', 'Chennai', 'Intercity', 'BadiGadi', 'Rault']

        random_train = random.choice(train_name)


        fare = [50, 100, 150, 200, 175, 245, 485, 152, 300, 350, 500]

        fare_random = random.choice(fare)

        Bookclass.tr = random_train

        Bookclass.fr = fare_random


        print(

            f"\n ' ' ' Fare for {Bookclass.tr} Express all over India is :- {Bookclass.fr} Rupees /- ' ' ' ")


        Bookclass.account = int(

            input("\n : Give your Account number for Fees  :- "))

        Fees = input(

            "\n : Type ' Yes ' for Confirming and Type ' No ' for Declining :- ")

        if Fees == 'Yes':

            print("\n : Your ticket has been sended to your gmail_Id ")

            Bookclass.printdata()

        elif Fees == 'No':

            pass

        else:

            print("\n : Kindly choose valid option !")


    elif instruction == 'Cancel':

        Cancelclass = cancel()

        Cancelclass.name = input(" : Type your name :- ")

        if Cancelclass.name in a:

            pass

        else:

            print(" : Kindly Type your name correctly ! ")

            continue


        Cancelclass.serial = input(" : Type your serial no :- ")

        if Cancelclass.serial in serial:

            Cancelclass.si()

            a.remove(Cancelclass.name)

        else:

            print(" : Type your serial name correctly !")


    elif instruction == 'Check':

        CHECK = input(" : Type your name --> ")

        if CHECK in a:

            print(" : Yes your name is present in our database !")

        else:

            print(

                " : Sorry your name is not present in our database , Kindly call at our Helpline no . ")

    else:

        print("\n : Kindly type given keyword ! ")


    print("\n  \t\t\t\t******* THANKS FOR VISITING INDIAN RAILWAYS *******\n\n")


Comments

Popular posts from this blog

1st Blog..