GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PythonIBM/Ejercicio_herencia.py at master · 1975Pepe/PythonIBM

Expand file tree

/

Ejercicio_herencia.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
55 lines (36 loc) · 1.31 KB
/

Ejercicio_herencia.py

Copy path

File metadata and controls

55 lines (36 loc) · 1.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
class Vehiculo():
def __init__(self, marca, modelo):
self.marca = marca
self.modelo = modelo
self.color = "Negro"
self.arrancado = False
self.parado = True
def arrancar(self):
self.arrancado = True
self.parado = False
def parar(self):
self.parado = True
self.arrancado = False
def resumen(self):
print("Marca:", self.marca, "\n", "Modelo:", self.modelo, "\n", "Color:", self.color, "\n", "Está arrancado:",
self.arrancado, "\n", "Está parado:", self.parado)
miCoche = Vehiculo("Renault", "Megane")
miCoche.arrancar()
miCoche.resumen()
class Moto(Vehiculo):
is_carenado = False
# Método propio de la clase Moto, no heredado del padre.
def poner_carenado(self):
self.is_carenado = True
# La clase Moto sobrescribe el método resumen() heredado del padre
def resumen(self):
print("El modelo es una moto", "\n", "Marca:", self.marca, "\n", "Modelo:", self.modelo, "\n", "Color:", self.color,
"\n", "Está arrancado:", self.arrancado, "\n", "Está parado:", self.parado, "\n", "Tiene carenado:", self.is_carenado)
miMoto = Moto("Kawasaki", "Ninja")
miMoto.resumen()
class kwad(Moto):
pass
miKwad = kwad("Linhai", "LH 500")
miKwad.resumen()
miMoto = Moto("Kawasaki", "Ninja")
miMoto.resumen()
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.