-
Notifications
You must be signed in to change notification settings - Fork 0
/
p1113.py
89 lines (72 loc) · 2.08 KB
/
p1113.py
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
from random import randint
import csv
class Car:
"""
some docummens
and this is also the doc
.....
"""
color = 'red'
gas_mileage = 0.1
gas_level = 50
position = 0
def __init__(self, color):
self.color = "blue"
def move(self, distance):
'Move a distance'
d = self.gas_level / self.gas_mileage
actual = min (d, distance)
self.position = self.position + distance
self.gas_level = self.gas_level - distance * distance
def saveToCSV(self):
with open("csv.csv", "w") as file:
csvWriter = csv.writer(file)
csvWriter.writerow(["total position", self.position])
def readCSV(self):
with open("csv.csv", "r") as file:
reader = csv.reader(file)
for row in reader:
print(row)
class ElectricCar(Car):
price = 20000
tire_circle = 99
def __init__(self):
Car.__init__(self, "blue")
def reprice(self, new_price):
self.price = new_price
def move(self, distance):
self.changeTire(distance)
self.position = self.position + distance
def changeTire(self, distance):
f = ( self.position + distance ) // self.tire_circle
for i in f:
print("change tire at {} time and go in this journey ".format(i))
myCar = ElectricCar()
myCar.reprice(15647)
print(myCar.price)
myCar.move(randint(1, 9999))
print(myCar.position)
myCar.move(randint(1, 9999))
print(myCar.position)
myCar.move(randint(1, 9999))
print(myCar.position)
##class Employee:
## def doWork(self):
## print("working...")
##
##
##
##class newE(Employee):
## pass
##class manager(Employee):
## def doWork(self):
## print("chat on phone")
##car.move(500)
##print(car.position)
##car.move(600)
##print(car.position)
##car.move(50)
##print(car.position)
##car.saveToCSV()
##car.readCSV()
##print(car.move(23).__doc__)