class airlineTicket:
    def __init__(self, start, destination, dateoftravel, firstClass,\
                 economy, business, price):
        self.start = start
        self.destination = destination
        self.dateoftravel = dateoftravel
        self.firstClass = firstClass
        self.economy = economy
        self.business = business
        self.price = price

Design a class for an airline ticket. Some of the fields of an airline ticket are start, destination, date of travel, class(economy, first class, business class), price of ticket, number of people traveling, and name of the primary person.

Instead of

self.firstClass = firstClass
self.economy = economy
self.business = business

which is redundant, i.e. you always have all 3, use a "class" variable that you set to "first", "economy", or "business". Also you don't have number of people or name.

I am confused about how this needs to be printed little help.

Example:

class AirlineTicket:
    # by convention capitalize class names
    def __init__(self, name, orig, dest, travel_date, travel_class, price):
        # assign parameters to the instance self
        self.name = name
        self.origination = orig
        self.destination = dest
        self.travel_date = travel_date
        self.travel_class = travel_class
        self.price = price

    def info(self):
        # format the info string
        info_str = " %s travels %s class\n from %s to %s on %s"
        info = info_str % (self.name, self.travel_class, self.origination,
                           self.destination, self.travel_date)
        return info


# AirlineTicket(name, orig, dest, travel_date, travel_class, price)
# gether data
name = "Ted Trump"
orig = "JFK"
dest = "LAX"
travel_date = "12/23/2012"
travel_class = "first"
price = 1820.50

# create unique instance for this traveler
tedtru = AirlineTicket(name, orig, dest, travel_date, travel_class, price)

# test this instance
print(tedtru.info())

'''my result >>>
 Ted Trump travels first class
 from JFK to LAX on 12/23/2012
'''
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.