-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoop.py
More file actions
200 lines (128 loc) · 4.24 KB
/
oop.py
File metadata and controls
200 lines (128 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# class Number:
# def sum(self):
# return self.a +self.b # type: ignore
# num = Number()
# num.a = int(input("Enter A Number\n"))
# num.b = int(input("Enter Another Number\n"))
# s = num.sum()
# print(f"The sum of the above numbers is {s}")
# # oop project 1
# class RailwayForm:
# type = "RailwayForm"
# def printData(self):
# print(f"Passengers' Name\n {self.name}")
# print(f"Passengers' Train\n {self.train}")
# print(f"Passengers' Beginning Of Journey\n {self.beginning}")
# print(f"Passengers' Destination Of Journey\n {self.destination}")
# akshatsApplication = RailwayForm()
# akshatsApplication.name = "Akshat"
# akshatsApplication.train = "Rajdhani Express"
# akshatsApplication.destination = "Kolkata, West Bengal, India"
# akshatsApplication.beginning = "New Delhi, India"
# akshatsApplication.printData() # oop project 2
# class Staff:
# workspace = "Graphics Code"
# salary = 10000
# def __init__(self, age, country, name):
# self.age = age
# self.country = country
# self.name = name
# print(f'''Staff Details:
# Name: {self.name}
# Age: {self.age}
# Country: {self.country}
# ''')
# aero = Staff("Akshat Singh",15, "India")
# gatik = Staff()
# adnan = Staff()
# wadhwa = Staff()
# gatik.salary = 5000
# wadhwa.salary = 40000
# print(f"{Staff.workspace}'s Staffs Salary List")
# print(f"Salary Of Gatik Is {gatik.salary} Per Month\n Per Annum = {gatik.salary*12}")
# print(f"Salary Of Adnan Is {adnan.salary} Per Month\n Per Annum = {adnan.salary*12}")
# print(f"Salary Of Wadhwa Is {wadhwa.salary} Per Month\n Per Annum = {wadhwa.salary*12}")
# oop project 3
# class Nigger:
# Nigger = "Nigga"
# @staticmethod # revoked the usage of self
# def getgud():
# print("You Are A Nigga")
# aditya = Nigger()
# aditya.getgud()
# class Programmer:
# Company = "Microsoft"
# def __init__(self, name, language, unit):
# self.language = language
# self.name = name
# self.unit = unit
# # details
# print("Staff Details")
# def getInfo(self):
# print(f'''
# Name = {self.name}
# Language = {self.language}
# Unit = {self.unit}
# ''')
# edward = Programmer("Edward", "C, C++ and C#", "XBox")
# james = Programmer("James", "Java", "Minecraft Java")
# jack = Programmer("Jack", "C, C++, C#, Go, Java, JavaScript, PHP, Python, Ruby, Scala, and TypeScript", "GitHub")
# edward.getInfo()
# james.getInfo()
# jack.getInfo()
# class calculator:
# def __init__(self, num):
# self.number = num
# def square(self):
# print(f"the sqaure of {self.number} is {self.number **2}")
# def squareRoot(self):
# print(f"the sqaure_root of {self.number} is {self.number **0.5}")
# def cube(self):
# print(f"the cube of {self.number} is {self.number **3}")
# sq = int(input("Enter the number of which you want sqaure of\n"))
# a = calculator(sq)
# a.square()
# a.squareRoot()
# a.cube()
# class Sample():
# a = "Aero"
# obj = Sample()
# obj.a = "Neetu"
# print(Sample.a)
# print(obj.a)
# # end
class Train():
def __init__(self, name, fare, seats):
self.name = name
self.fare = fare
self.seats = seats
def getStatus(self):
print(f'''
**{self.name}**
Engine Name: {self.name}
Seats Available: {self.seats}
----------------------------------
''')
def fareInfo(self):
print(f'''
**Fare**
Ticket Price: Rs.{self.fare}
----------------------------------
''')
def bookTicket(self):
if (self.seats>0):
self.seats = self.seats - 1
print(f'''
**Reservation**
Ticket Booked Successfully!
Seat Number: {self.seats}
----------------------------------
''')
else:
print("Ticket Booked Unsuccessfully [out-of-seats]")
intercity = Train("Intercity Express: 241122", 90, 2)
intercity.getStatus()
intercity.fareInfo()
intercity.bookTicket()
# intercity.bookTicket()
# intercity.bookTicket()