Problem Statement:
There’s a ticket-selling booth at the cricket stadium from where visitors have to buy tickets and only then, do they get entry. The ticket fare for the concert is Rs. 500. The ticket counter keeps watch on the total amount collected and the number of people who visited the stadium.
Design a class for the ticket counter containing-
- Data members:
- Number of visitors
- Total amount collected
- Member Functions:
- To increment the number of visitors and the total amount.
- To display the total number of visitors and the total amount collected so far.
- Also, initialize the members.
Code for Ticket selling in Cricket Stadium using Python:
class Counter:
#class variables to initialize the members
NoofVisitors = 0
TotalAmount = 0
#function for incrementing the visitors and tolling total amount
def sellticket(self):
#increment the number of visitors
Counter.NoofVisitors +=1
#add the ticket fair to the total amount
Counter.TotalAmount +=500
#function to display total number of visitors and amount collected
def display(self):
#display number of visitors
print("Total Number of Visitors: ", Counter.NoofVisitors)
#display total amount collected
print("Total Amount Collected: ",Counter.TotalAmount)
#test this class
C1 = Counter()
C1.sellticket()
C1.display()
C2 = Counter()
C2.sellticket()
C2.display()
Output: for Ticket selling in Cricket Stadium using Python
Also Read:
- Hyphenate Letters in Python
- Earthquake in Python | Easy Calculation
- Striped Rectangle in Python
- Perpendicular Words in Python
- Free shipping in Python
- Raj has ordered two electronic items Python | Assignment Expert
- Team Points in Python
- Ticket selling in Cricket Stadium using Python | Assignment Expert
- Split the sentence in Python
- String Slicing in JavaScript
- First and Last Digits in Python | Assignment Expert
- List Indexing in Python
- Date Format in Python | Assignment Expert
- New Year Countdown in Python
- Add Two Polynomials in Python
- Sum of even numbers in Python | Assignment Expert
- Evens and Odds in Python
- A Game of Letters in Python
- Sum of non-primes in Python
- Smallest Missing Number in Python
- String Rotation in Python
- Secret Message in Python
- Word Mix in Python
- Single Digit Number in Python
- Shift Numbers in Python | Assignment Expert
- Weekend in Python
- Shift Numbers in Python | Assignment Expert
- Temperature Conversion in Python
- Special Characters in Python
- Sum of Prime Numbers in the Input in Python