classesherançasimples.py
unknown
python
10 months ago
2.1 kB
24
Indexable
import time from datetime import datetime class Camera: def __init__(self,brand,megapixels,storage): self.brand = brand self.megapixels = megapixels self.storage = storage def show_features(self): print("Showing features...") time.sleep(1) print(f"Brand: {self.brand}") print(f"Megapixels: {self.megapixels}") print(f"Storage: {self.storage}") def take_a_picture(self): print(f"Taking picture with the cam {self.brand} and {self.megapixels} megapixels in {self.storage} at {datetime.now()}.") def storage_a_pic(self,picture): print(f"Storing picture:{picture} in storage.") class CameraPhone(Camera): def __ini__(self,brand,megapixels,storage,ram,price,number_cams): super().__init__(self,brand,megapixels,storage) self.ram = ram self.price = price self.number_cams = number_cams def apply_filter(self, filter, picture): print(f"Applying filter {filter} in {picture} at {datetime.now()}.") def show_features_2(self): print(f"Brand:{self.brand}") print(f"Megapixels:{self.megapixels}") print(f"Storage:{self.storage}") print(f"Ram:{self.ram}") print(f"Price:{self.price}") print(f"Number_cams:{self.number_cams}") def take_picture(self,camera_to_use): print(f"taking a pic with {camera_to_use} with quality {self.megapixels}.") class SecurityCam(Camera): def __init__(self,brand,megapixels,storage,hours_to_use,rotate): super().__init__(brand,megapixels,storage) self.hours_to_use = hours_to_use self.rotate = rotate def rotate(self,direction,angle): print(f"Rotating camera in {direction} with angle of {angle}.") camera_generica = Camera('Sony','40mp','60gb') camera_generica.show_features() camera_generica.take_a_picture() camera_generica.storage_a_pic("imageGoW.jpeg") print("-"*100)
Editor is loading...
Leave a Comment