Este grupo especializado pasados muchos días de trabajo y de recopilar de información, han obtenido la solución, esperamos que te sea útil para tu plan.
Ejemplo: programa de python de coche
classCar:def__init__(self, year, make, speed):
self.__year_model = year
self.__make = make
self.__speed =0defset_year_model(self, year):
self.__year_model = year
defset_make(self, make):
self.__make = make
defset_speed(self, speed):
self.__speed =0defget_year_model(self):return self.__year_model
defget_make(self):return self.__make
defget_speed(self):return self.__speed
#methodsdefaccelerate(self):
self.__speed +=5defbrake(self):
self.__speed -=5defget_speed(self):return self.__speed
defmain():
year =input('Enter the car year: ')
make =input('Enter the car make: ')
speed =0
mycar = Car(year, make, speed)#Accelerate 5 times
mycar.accelerate()print('The current speed is: ', mycar.get_speed())
mycar.accelerate()print('The current speed is: ', mycar.get_speed())
mycar.accelerate()print('The current speed is: ', mycar.get_speed())
mycar.accelerate()print('The current speed is: ', mycar.get_speed())
mycar.accelerate()print('The current speed is: ', mycar.get_speed())#Brake 5 times
mycar.brake()print('The current speed after brake is: ', mycar.get_speed())
mycar.brake()print('The current speed after brake is: ', mycar.get_speed())
mycar.brake()print('The current speed after brake is: ', mycar.get_speed())
mycar.brake()print('The current speed after brake is: ', mycar.get_speed())
mycar.brake()print('The current speed after brake is: ', mycar.get_speed())#Call the main function
main()
Aquí tienes las reseñas y calificaciones
Recuerda algo, que puedes optar por la opción de esclarecer tu experiencia si te fue preciso.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)