-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.exe
More file actions
24 lines (24 loc) · 683 Bytes
/
Copy path3.exe
File metadata and controls
24 lines (24 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Car:
def __init__(self,make,model,year):
self.make=make
self.model=model
self.year=year
self.running=False
def start(self):
if not self.running:
self.running=True
print(self.year,self.make,self.model,"started.")
else:
print("Car is already running.")
def stop(self):
if self.running:
self.running=False
print(self.year,self.make,self.model,"stopped")
else:
print("Car is already stopped.")
car1=Car("toyota","corolla",2022)
car2=Car("honda","civic",2021)
car1.start()
car1.stop()
car2.start()
car2.stop()