agent

Finished
11class SpaceAge:
2 """
3 A class to calculate the age of a person on different planets in our solar system
4 based on their age in seconds.
5
6 The class takes an age in seconds and provides methods to calculate the age
7 on various planets, accounting for their orbital periods relative to Earth.
8
9 Args:
10 seconds (int): The age in seconds
11 """
12
13 # Earth year in seconds
14 EARTH_YEAR_SECONDS = 31557600
15
16 # Orbital periods in Earth years
17 ORBITAL_PERIODS = {
18 'mercury': 0.2408467,
19 'venus': 0.61519726,
20 'earth': 1.0,
21 'mars': 1.8808158,
22 'jupiter': 11.862615,
23 'saturn': 29.447498,
24 'uranus': 84.016846,
25 'neptune': 164.79132
26 }
27
228 def __init__(self, seconds: int) -> None:
3 pass
29 """
30 Initialize the SpaceAge object with an age in seconds.
31
32 Args:
33 seconds (int): The age in seconds
34
35 # Handled Edge Cases: None for this constructor
36 """
37 self.seconds = seconds
38
39 def _calculate_age_on_planet(self, planet: str) -> float:
40 """
41 Helper method to calculate age on a specific planet.
42
43 Args:
44 planet (str): The name of the planet
45
46 Returns:
47 float: The age on the specified planet, rounded to 2 decimal places
48 """
49 # Edge Case: Handle negative seconds by returning negative age
50 if self.seconds < 0:
51 return round((self.seconds / self.EARTH_YEAR_SECONDS) / self.ORBITAL_PERIODS[planet], 2)
52
53 return round((self.seconds / self.EARTH_YEAR_SECONDS) / self.ORBITAL_PERIODS[planet], 2)
54
55 def on_mercury(self) -> float:
56 """
57 Calculate the age on Mercury.
58
59 Returns:
60 float: The age on Mercury, rounded to 2 decimal places
61
62 # Handled Edge Cases: Negative seconds
63 """
64 return self._calculate_age_on_planet('mercury')
65
66 def on_venus(self) -> float:
67 """
68 Calculate the age on Venus.
69
70 Returns:
71 float: The age on Venus, rounded to 2 decimal places
72
73 # Handled Edge Cases: Negative seconds
74 """
75 return self._calculate_age_on_planet('venus')
76
77 def on_earth(self) -> float:
78 """
79 Calculate the age on Earth.
80
81 Returns:
82 float: The age on Earth, rounded to 2 decimal places
83
84 # Handled Edge Cases: Negative seconds
85 """
86 return self._calculate_age_on_planet('earth')
87
88 def on_mars(self) -> float:
89 """
90 Calculate the age on Mars.
91
92 Returns:
93 float: The age on Mars, rounded to 2 decimal places
94
95 # Handled Edge Cases: Negative seconds
96 """
97 return self._calculate_age_on_planet('mars')
98
99 def on_jupiter(self) -> float:
100 """
101 Calculate the age on Jupiter.
102
103 Returns:
104 float: The age on Jupiter, rounded to 2 decimal places
105
106 # Handled Edge Cases: Negative seconds
107 """
108 return self._calculate_age_on_planet('jupiter')
109
110 def on_saturn(self) -> float:
111 """
112 Calculate the age on Saturn.
113
114 Returns:
115 float: The age on Saturn, rounded to 2 decimal places
116
117 # Handled Edge Cases: Negative seconds
118 """
119 return self._calculate_age_on_planet('saturn')
120
121 def on_uranus(self) -> float:
122 """
123 Calculate the age on Uranus.
124
125 Returns:
126 float: The age on Uranus, rounded to 2 decimal places
127
128 # Handled Edge Cases: Negative seconds
129 """
130 return self._calculate_age_on_planet('uranus')
131
132 def on_neptune(self) -> float:
133 """
134 Calculate the age on Neptune.
135
136 Returns:
137 float: The age on Neptune, rounded to 2 decimal places
138
139 # Handled Edge Cases: Negative seconds
140 """
141 return self._calculate_age_on_planet('neptune')
Test NameStatus
test_age_on_earth
Pass
test_age_on_jupiter
Pass
test_age_on_mars
Pass
test_age_on_mercury
Pass
test_age_on_neptune
Pass
test_age_on_saturn
Pass
test_age_on_uranus
Pass
test_age_on_venus
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.