# -*- coding: utf-8 -*- """Start_Of_Object_Orented_Code.ipynb Automatically generated by Colab. Original file is located at https://colab.research.google.com/drive/1wPUj2zi6OC7igZZ9IVfBdjhWTXpuHXWL this code generates a chance that the skin sill be damages """ import random class UVRay: def __init__(self, intensity, duration, ray_type='UVA', location_factor=1.0): self.intensity = intensity # Base intensity of UV rays (0 to 1 scale) self.duration = duration # Duration of exposure in minutes self.ray_type = ray_type # 'UVA' or 'UVB' self.location_factor = location_factor # Location factor to modify intensity def emit(self): # Modify the intensity based on location and weather adjusted_intensity = self.intensity * self.location_factor return adjusted_intensity class Skin: def __init__(self, skin_type, color, genetic_sensitivity=1.0, sunscreen_factor=1.0): self.skin_type = skin_type # 'light', 'medium', 'dark' self.color = color # Color representation (e.g., RGB or descriptive) self.genetic_sensitivity = genetic_sensitivity # Sensitivity to UV damage (multiplier) self.sunscreen_factor = sunscreen_factor # Sunscreen protection factor (0 to 1) self.damage_level = 0 # Immediate damage self.cumulative_damage = 0 # Cumulative damage over time self.block_probabilities = { 'light': 0.2, # Light skin has a 20% chance to block UV damage 'medium': 0.5, # Medium skin has a 50% chance to block UV damage 'dark': 0.8 # Dark skin has an 80% chance to block UV damage } def absorb_uv(self, uv_ray): # Adjust the UV intensity based on sunscreen protection effective_intensity = uv_ray.intensity * (1 - self.sunscreen_factor) # Calculate the probability of blocking damage based on skin type block_probability = self.block_probabilities[self.skin_type] # Generate a random number between 0 and 1 to simulate whether the UV is blocked if random.random() < block_probability: print(f"UV rays were blocked by {self.skin_type} skin.") else: # Simulate UVA and UVB effects if uv_ray.ray_type == 'UVA': # UVA causes deeper damage or aging damage = effective_intensity * 0.5 # Less immediate damage, more long-term effects elif uv_ray.ray_type == 'UVB': # UVB causes more immediate damage (sunburn) damage = effective_intensity * 1.0 # Full intensity of damage # Apply genetic sensitivity (e.g., people with sensitive skin take more damage) damage *= self.genetic_sensitivity self.damage_level = min(self.damage_level + damage, 100) self.cumulative_damage += damage print(f"UV rays caused damage. Skin damage is now {self.damage_level}%.") def heal(self): # Heal the skin over time (simulate natural recovery) self.damage_level = max(self.damage_level - 1, 0) print(f"Skin is healing. Current damage level: {self.damage_level}%.") # Simulate long-term effects of cumulative damage (e.g., photoaging, skin cancer risk) if self.cumulative_damage > 200: print("Risk of skin cancer increases due to cumulative damage.") elif self.cumulative_damage > 100: print("Photoaging effects becoming noticeable.") class Damage: @staticmethod def calculate_damage(skin, uv_ray): # Calculate how much damage a given skin type and UV exposure causes skin.absorb_uv(uv_ray) # Example Usages: # Example 1: Light skin with high genetic sensitivity, no sunscreen, and moderate UVB exposure skin1 = Skin(skin_type='light', color='light', genetic_sensitivity=1.5, sunscreen_factor=0.0) uv_ray1 = UVRay(intensity=0.8, duration=30, ray_type='UVB', location_factor=1.2) Damage.calculate_damage(skin1, uv_ray1) skin1.heal() # Example 2: Medium skin with sunscreen protection and mild UVA exposure skin2 = Skin(skin_type='medium', color='tan', genetic_sensitivity=1.0, sunscreen_factor=0.5) uv_ray2 = UVRay(intensity=0.6, duration=45, ray_type='UVA', location_factor=1.0) Damage.calculate_damage(skin2, uv_ray2) skin2.heal() # Example 3: Dark skin, genetic sensitivity of 1.0, with high protection (high SPF sunscreen) skin3 = Skin(skin_type='dark', color='dark brown', genetic_sensitivity=1.0, sunscreen_factor=0.8) uv_ray3 = UVRay(intensity=0.9, duration=60, ray_type='UVB', location_factor=1.1) Damage.calculate_damage(skin3, uv_ray3) skin3.heal() # Example 4: Light skin with low sunscreen protection, long exposure to UVB rays skin4 = Skin(skin_type='light', color='fair', genetic_sensitivity=1.0, sunscreen_factor=0.3) uv_ray4 = UVRay(intensity=0.9, duration=120, ray_type='UVB', location_factor=1.5) Damage.calculate_damage(skin4, uv_ray4) skin4.heal() # Example 5: Medium skin, genetic sensitivity of 2.0, long UVA exposure, no sunscreen skin5 = Skin(skin_type='medium', color='medium', genetic_sensitivity=2.0, sunscreen_factor=0.0) uv_ray5 = UVRay(intensity=0.5, duration=90, ray_type='UVA', location_factor=1.3) Damage.calculate_damage(skin5, uv_ray5) skin5.heal()