repl.it
Python

No description

fork
loading
Files
  • main.py
main.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
class Car():
    """A simple attempt to represent a car"""

  def __init__(self, make, model, year):
    """Initialize attributes to describe a car"""
    self.make = make
    self.model = model
    self.year = year
    self.meter_reading = 0

  def get_descriptive_name(self):
    """Returns a neatly formated descriptive name"""
    long_name = str{self.year} + '' + {self.make} + '' + {self.model}
    return long_name.tittle())


  def read_meter(self):
    print f"This car has {self.meter_reading} miles on it."


  def update_meter(self. mileage):
    """set new value for the meter"""
    if mileage >= self.meter_reading:
      self.meter_reading = mileage 
    else:
      print("You can't roll back the meter to loser.")

    def oncrement_odometer(self, miles):
      """increments the odometer by miles"""
      self.meter_reading += miles

my_new_car = Car("Ferrari", "F430 Challange", "2006")
print(my_new_car.get_descriptive_name())
my_new_car.read_meter()

class Electriccar(Car):
  def __init__(self, make, model, year):
    super()._init_(make, model, year)

my_tesla = Electriccar("tesla", "Model x", "2099")
print(my_tesla.get_descripbe_battery()