Question

In: Computer Science

create a python program You are assigned to implement the following baggage-check-in system at the airport....

create a python program

You are assigned to implement the following baggage-check-in system at the airport.

The system keeps track of data for the following information: passenger, bags, and tickets.

The program must maintain passenger details like name, address, phone number, and the number of bags. Each passenger can have multiple bags and each bag has length, width, height, and weight. The passenger also has a ticket. The tickets are of two types, either a first-class ticket or an economy-ticket. The maximum weight allowed for a first-class ticket is 40 Kilos and the maximum weight allowed for an economy-ticket is 30 Kilos. The program must display all the details of the passenger, ticket, and number of bags and allowed weight. If the weight exceeds that of the respective ticket class, then the program will give appropriate message to indicate that the passenger cannot travel. Your program must throw an exception to indicate the failure.

Requirements

  • Implement the following functions:
    1. checkOverweigth() # Given the ticket number, check if the total weight of all bags exceeds limit
    2. checkPassengerClass() # Given the ticket number, the class of the ticket is given
    3. displayPassengerDetails() # Given the ticket number, display all check-in details of a passenger
  • Student is required to identify classes, related attributes, and behaviors. Students are free to add as many attributes as required. The appropriate access modifiers (private, public, or protected) must be used while implementing class relationships. Proper documentation of code is mandatory.
  • Student must also test the code, by creating at-least three objects. All classes must have a display function, and the program must have functionality to print current state of the objects.

Solutions

Expert Solution

CONCEPT: WE USED HERE SIMPLE CLASS AND OBJECTS CONCEPTS WE TAKE HERE CLASS CONSTRUCTORS AND VARIOUS VALUES TO GET THE CHECK IN SYSTEM

''' class bags having the attributes as

given here below.. length width, and height

as given below... we fill all the heights

weights as below'''

class bags:

    

    def __init__(self,l1,wd1,h1,w1):

        self.length=l1

        self.width=wd1

        self.height=h1

        self.weight=w1

        

'''we have the check_in_system class as given below

code .. we have all the attributes as

we take the constructors and the varioud

function.s we calculate_weight_of_all as extra

member function...'''

class check_in_system:

    

    #constructors for assigning all the values to the attributes..

    def __init__(self,n1,t1,ad1,nos,bags_no):

       

        self.ticket_no=t1

        self.name=n1

        self.address=ad1

        self.phone_no=nos

        self.no_of_bags=bags_no

        self.Pclass=""

        self.total_weight1=0

        

    def calculate_weight_of_all(self):

        total=0.0

        list=[]

        '''enter the weight of all the bags alogn with length wi....

        and then we take the each obj of bags type and then we

        add all the weights'''

        print("enter the length width,height & weight of each bags")

        for i in range(self.no_of_bags):

            l1=int(input())

            wd1=int(input())

            h1=int(input())

            w1=int(input())

            

            list.append( bags(l1,wd1,h1,w1) )

        

        for obj in list:

            total+=obj.weight

        self.total_weight1=total

        #we get the total and return

        return total

    

    #this is used to checkPassengerClass from the ticket_no..        

    def checkPassengerClass(self,ticket_no):

        

        '''this is just anymously taken as if the ticket_no > 61345 then we think it as first_class.. and

        else display_passenger_details'''

        if ticket_no > 61345:

            Pclass1="first_class"

        else:

            Pclass1="economy_class"

            

        self.Pclass=Pclass1

        

        return Pclass1    

            

    '''we check for checkOverWeight using this function here..

    we have this as we count all the weights and then we

    use the Pclass1 as economy_class and assing as given code..'''

    def checkOverWeight(self,ticket_no):

        

        Pclass1=self.checkPassengerClass(ticket_no)

        total_weight=self.calculate_weight_of_all()

        

        if(Pclass1=="first_class"):

            if(total_weight>40):

                return True

            else:

                return False

        elif(Pclass1=="economy_class"):

            if(total_weight>30):

                return True

            else:

                return False

                

        

    def display_passenger_details(self,ticket_no):

        

        c1=self.checkPassengerClass(ticket_no)

        

        if(self.checkOverWeight(ticket_no)==True):

            print("cant traver checkOverWeight exception occured")

            return

        

        else:

            print("name is ",self.name)

            print("address is: ",self.address)

            print("phone_no :",self.phone_no)

            print("no_of_bags",self.no_of_bags)

            print("total_weight is:",self.total_weight1)

            print("class of the passenger is: ",self.Pclass)

            print("")

            

def main():

    #object 1 and 2 and 3 are below:

    

    air1= check_in_system("newton",23435,"big city newyork",56545444,1)

    air1.display_passenger_details(23435)

    

    air2=check_in_system("sljf",4324,"ldkjfdklf",344545567,2)

    air2.display_passenger_details(4324)

    

    air3=check_in_system("sljf",432456,"ldkjfdklf",344545567,1)

    air3.display_passenger_details(432456)

    

    

if __name__ =="__main__":

    main()

    

    Input:

4

6

4

23

4

6

4

23

5

8

9

12

6

12

89

15

Output:

enter the length width,height & weight of each bags

name is newton

address is: big city newyork

phone_no : 56545444

no_of_bags 1

total_weight is: 23.0

class of the passenger is: economy_class

enter the length width,height & weight of each bags

cant traver checkOverWeight exception occured

enter the length width,height & weight of each bags

name is sljf

address is: ldkjfdklf

phone_no : 344545567

no_of_bags 1

total_weight is: 15.0

class of the passenger is: first_class






Note: in case of nay query please ask in comment

Thank you

Upvote if helpful


Related Solutions

Create this on Python Write a program that asks for three numbers. Check first to see...
Create this on Python Write a program that asks for three numbers. Check first to see that all numbers are different. If they’re not different, then exit the program. Otherwise, display the largest number of the three. Outputs: - Enter the first number: 4 - Enter the second number: 78 - Enter the third number: 8 (The largest number is 78.) Tasks - Complete the algorithm manually without using any built-in functions to find the largest number on list. -...
Implement a python program in file named tarvel.py. Create an empty dictionary named responses. Implement while...
Implement a python program in file named tarvel.py. Create an empty dictionary named responses. Implement while loop to take in user's name and desired destination for as long as there are user inputs. Prompt user to input yes to continue and no to quit. Prompt for user's name. Receive the name into the program and save it as the value of name variable. Prompt user for their desired vacation destination. Receive response and save it as the value of a...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
In Python Create customer information system as follows: Python 3 Create customer information system as follows:...
In Python Create customer information system as follows: Python 3 Create customer information system as follows: Ask the user to enter name, phonenumber, email for each customer. Build a dictionary of dictionaries to hold 10 customers with each customer having a unique customer id. (random number generated) Take the keys of the above mentioned dictionary which are customer ids and make a list. Ask the use to enter a customer id and do a binary search to find if the...
you will create a program with Java to implement a simplified version of RSA cryptosystems. To...
you will create a program with Java to implement a simplified version of RSA cryptosystems. To complete this project, you may follow the steps listed below (demonstrated in Java code) to guide yourself through the difficulties. Step I Key-gen: distinguish a prime number (20 pts) The generation of RSA's public/private keys depends on finding two large prime numbers, thus our program should be able to tell if a given number is a prime number or not. For simplicity, we define...
I have a python program that must check if an integer is the sum of the...
I have a python program that must check if an integer is the sum of the squares of four consecutive prime numbers. However, when I run the program, it goes into an infinite while loop, and it doesn't give me any answer. I can only use the while, if, else, True and False commands. The code I'm using is n1=2   n2=3   n3=5   n4=7   n = int(input("n: "))   if (n==(n1**2)+(n2**2)+(n3**2)+(n4**2)):     print(n1,n2,n3,n4)   else :     i = 2     pr = True     next =...
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will...
Create a program (Python) YourFirstnameLastnameA06b.py to ask the user to create a password: The user will first enter a password, then enters the same password again; If the second input is the same as first one, the user successfully creates the password. Print “Well done.”; Otherwise, the user will be directed to repeat the whole process (go to step 1.)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT